Skip to content

Commit 76783c8

Browse files
committed
Update readme for left-right change
1 parent 4dd9d83 commit 76783c8

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ This is an example class that gets a tweet (type `Status`) from a remote HTTP AP
2323
import { Failure, fold, Initialized, Pending, RemoteData, Success } from '@abraham/remotedata';
2424
import { Status } from 'twitter-d';
2525

26-
// Define what the RemoteData Success and Failure types will be.
27-
type State = RemoteData<Status, number>;
26+
// Define what the RemoteData Failure and Success types will be.
27+
type State = RemoteData<number, Status>;
2828

2929
class Thing {
3030
// Set the initial state as Initialized.
@@ -54,20 +54,20 @@ class Thing {
5454
}
5555

5656
private get view(state: State): (state: State) => string {
57-
// Use `fold` to easily define logic based on the state.
58-
// Fold takes four methods as parameters in the order of Initialized, Pending, Success, Failure
59-
// and return a method method that takes a `RemoteData` instance as a parameter.
60-
// When returned method gets called with a `RemoteData` state, the method matching the current
57+
// Use `fold` to easily define logic based on the current state.
58+
// Fold takes four methods as parameters in the order of Initialized, Pending, Failure, and
59+
// Success and returns a method that takes a `RemoteData` state instance as a parameter. When
60+
// the returned method gets called with a `RemoteData` state, the method matching the correct
6161
// state gets called.
62-
return fold<string, Status, number>(
62+
return fold<string, number, Status>(
6363
// What to do if the state is Initialized.
6464
() => 'Initialized',
6565
// What to do if the request is Pending.
6666
() => 'Loading...',
67+
// What to do if the request fails.
68+
(error: number) => `Error: ${error}`,
6769
// What to do if the request succeeds.
6870
(status: Status) => `Got tweet from ${status.screen_name}`,
69-
// What to do if the request fails.
70-
(error: string) => `Error: ${error}`,
7171
);
7272
}
7373

@@ -86,3 +86,6 @@ References
8686
- [How Elm Slays a UI Antipattern](http://blog.jenkster.com/2016/06/how-elm-slays-a-ui-antipattern.html)
8787
- [Slaying a UI Antipattern with Angular](https://medium.com/@joanllenas/slaying-a-ui-antipattern-with-angular-4c7536fafc54)
8888
- [Slaying a UI Antipattern with Flow](https://medium.com/@gcanti/slaying-a-ui-antipattern-with-flow-5eed0cfb627b)
89+
- [Slaying a UI Antipattern in React](https://medium.com/javascript-inside/slaying-a-ui-antipattern-in-react-64a3b98242c)
90+
- [Slaying a UI Antipattern in Fantasyland](https://medium.com/javascript-inside/slaying-a-ui-antipattern-in-fantasyland-907cbc322d2a)
91+
- [Remote Data State as an Enum](http://holko.pl/2016/06/09/data-state-as-an-enum/)

0 commit comments

Comments
 (0)