Skip to content

Instantly share code, notes, and snippets.

@glortho
Last active July 21, 2017 21:24
Show Gist options
  • Select an option

  • Save glortho/81a14b0fef58e01f799bb35d62f28f42 to your computer and use it in GitHub Desktop.

Select an option

Save glortho/81a14b0fef58e01f799bb35d62f28f42 to your computer and use it in GitHub Desktop.

Revisions

  1. glortho revised this gist Jul 21, 2017. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion ApiDecoratorExample.jsx
    Original file line number Diff line number Diff line change
    @@ -9,8 +9,9 @@ const users = apiDecorator({
    @users
    export default class UsersDecorated extends React.Component {
    render() {
    const { list } = this.props.users;
    return (
    <span>{ this.props.users.$list().length } Users</span>
    <span>{ list().data.length } Users</span>
    )
    }
    }
  2. glortho revised this gist Jun 3, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ApiDecoratorExample.jsx
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ const users = apiDecorator({
    export default class UsersDecorated extends React.Component {
    render() {
    return (
    <span>{ this.props.users.$list().size } Users</span>
    <span>{ this.props.users.$list().length } Users</span>
    )
    }
    }
  3. glortho revised this gist May 25, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ApiDecoratorExample.jsx
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    import React from 'react'
    import apiDecorator from 'jetset/lib/decorator'
    import { apiDecorator } from 'jetset'

    const users = apiDecorator({
    url: "https://jsonplaceholder.typicode.com",
  4. glortho revised this gist May 25, 2017. 1 changed file with 7 additions and 8 deletions.
    15 changes: 7 additions & 8 deletions ApiDecoratorExample.jsx
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,16 @@
    import React from 'react';
    import Api from 'jetset/api';

    export const users = Component => props =>
    <Api url="https://jsonplaceholder.typicode.com" users="/users">
    <Component { ...props } />
    </Api>;
    import React from 'react'
    import apiDecorator from 'jetset/lib/decorator'

    const users = apiDecorator({
    url: "https://jsonplaceholder.typicode.com",
    users: "/users"
    })

    @users
    export default class UsersDecorated extends React.Component {
    render() {
    return (
    <span>{ this.props.users.$list().size } Users</span>
    );
    )
    }
    }
  5. glortho revised this gist May 17, 2017. 1 changed file with 6 additions and 7 deletions.
    13 changes: 6 additions & 7 deletions ApiDecoratorExample.jsx
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,17 @@
    import React from 'react';
    import Api from 'jetset/api';

    const sourcesSchema = require( '../schemas/sources' );

    export const sources = Component => props =>
    <Api url="http://localhost:3000/hub/api" sources={ sourcesSchema }>
    export const users = Component => props =>
    <Api url="https://jsonplaceholder.typicode.com" users="/users">
    <Component { ...props } />
    </Api>;


    @sources
    export default class SourcesDecorated extends React.Component {
    @users
    export default class UsersDecorated extends React.Component {
    render() {
    return (
    <span>{ this.props.sources.$list().size } Sources</span>
    <span>{ this.props.users.$list().size } Users</span>
    );
    }
    }
  6. glortho revised this gist May 11, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ApiDecoratorExample.jsx
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ export const sources = Component => props =>
    export default class SourcesDecorated extends React.Component {
    render() {
    return (
    <span>{ this.props.sources().size } Sources</span>
    <span>{ this.props.sources.$list().size } Sources</span>
    );
    }
    }
  7. glortho revised this gist May 3, 2017. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion ApiDecoratorExample.jsx
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@
    import React from 'react';
    import Api from 'jetset/api';

    const sourcesSchema = require( '../schemas/sources' );
  8. glortho created this gist May 3, 2017.
    19 changes: 19 additions & 0 deletions ApiDecoratorExample.jsx
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    import React from 'react';
    import Api from 'jetset/api';

    const sourcesSchema = require( '../schemas/sources' );

    export const sources = Component => props =>
    <Api url="http://localhost:3000/hub/api" sources={ sourcesSchema }>
    <Component { ...props } />
    </Api>;


    @sources
    export default class SourcesDecorated extends React.Component {
    render() {
    return (
    <span>{ this.props.sources().size } Sources</span>
    );
    }
    }