Skip to content

Instantly share code, notes, and snippets.

@zerobias
Created July 6, 2019 22:04
Show Gist options
  • Save zerobias/92672f8f6fc5e05816eed17ccd681cba to your computer and use it in GitHub Desktop.
Save zerobias/92672f8f6fc5e05816eed17ccd681cba to your computer and use it in GitHub Desktop.
{
"type": "root",
"children": [
{
"type": "thematicBreak",
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 1,
"column": 4,
"offset": 3
},
"indent": []
}
},
{
"type": "paragraph",
"children": [
{
"type": "text",
"value": "id: effector",
"position": {
"start": {
"line": 2,
"column": 1,
"offset": 4
},
"end": {
"line": 2,
"column": 13,
"offset": 16
},
"indent": []
}
}
],
"position": {
"start": {
"line": 2,
"column": 1,
"offset": 4
},
"end": {
"line": 2,
"column": 13,
"offset": 16
},
"indent": []
}
},
{
"type": "heading",
"depth": 2,
"children": [
{
"type": "text",
"value": "title: API Reference",
"position": {
"start": {
"line": 3,
"column": 1,
"offset": 17
},
"end": {
"line": 3,
"column": 21,
"offset": 37
},
"indent": []
}
}
],
"position": {
"start": {
"line": 3,
"column": 1,
"offset": 17
},
"end": {
"line": 4,
"column": 4,
"offset": 41
},
"indent": [
1
]
}
},
{
"type": "heading",
"depth": 3,
"children": [
{
"type": "text",
"value": "Top-Level Exports",
"position": {
"start": {
"line": 6,
"column": 5,
"offset": 47
},
"end": {
"line": 6,
"column": 22,
"offset": 64
},
"indent": []
}
}
],
"position": {
"start": {
"line": 6,
"column": 1,
"offset": 43
},
"end": {
"line": 6,
"column": 23,
"offset": 65
},
"indent": []
}
},
{
"type": "list",
"ordered": false,
"start": null,
"spread": false,
"children": [
{
"type": "listItem",
"spread": false,
"checked": null,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"title": null,
"url": "createEvent.md",
"children": [
{
"type": "text",
"value": "createEvent(name?)",
"position": {
"start": {
"line": 8,
"column": 4,
"offset": 70
},
"end": {
"line": 8,
"column": 22,
"offset": 88
},
"indent": []
}
}
],
"position": {
"start": {
"line": 8,
"column": 3,
"offset": 69
},
"end": {
"line": 8,
"column": 39,
"offset": 105
},
"indent": []
}
}
],
"position": {
"start": {
"line": 8,
"column": 3,
"offset": 69
},
"end": {
"line": 8,
"column": 39,
"offset": 105
},
"indent": []
}
}
],
"position": {
"start": {
"line": 8,
"column": 1,
"offset": 67
},
"end": {
"line": 8,
"column": 39,
"offset": 105
},
"indent": []
}
},
{
"type": "listItem",
"spread": false,
"checked": null,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"title": null,
"url": "createEffect.md",
"children": [
{
"type": "text",
"value": "createEffect(name?)",
"position": {
"start": {
"line": 9,
"column": 4,
"offset": 109
},
"end": {
"line": 9,
"column": 23,
"offset": 128
},
"indent": []
}
}
],
"position": {
"start": {
"line": 9,
"column": 3,
"offset": 108
},
"end": {
"line": 9,
"column": 41,
"offset": 146
},
"indent": []
}
}
],
"position": {
"start": {
"line": 9,
"column": 3,
"offset": 108
},
"end": {
"line": 9,
"column": 41,
"offset": 146
},
"indent": []
}
}
],
"position": {
"start": {
"line": 9,
"column": 1,
"offset": 106
},
"end": {
"line": 9,
"column": 41,
"offset": 146
},
"indent": []
}
},
{
"type": "listItem",
"spread": false,
"checked": null,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"title": null,
"url": "createStore.md",
"children": [
{
"type": "text",
"value": "createStore(defaultState)",
"position": {
"start": {
"line": 10,
"column": 4,
"offset": 150
},
"end": {
"line": 10,
"column": 29,
"offset": 175
},
"indent": []
}
}
],
"position": {
"start": {
"line": 10,
"column": 3,
"offset": 149
},
"end": {
"line": 10,
"column": 46,
"offset": 192
},
"indent": []
}
}
],
"position": {
"start": {
"line": 10,
"column": 3,
"offset": 149
},
"end": {
"line": 10,
"column": 46,
"offset": 192
},
"indent": []
}
}
],
"position": {
"start": {
"line": 10,
"column": 1,
"offset": 147
},
"end": {
"line": 10,
"column": 46,
"offset": 192
},
"indent": []
}
},
{
"type": "listItem",
"spread": false,
"checked": null,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"title": null,
"url": "createDomain.md",
"children": [
{
"type": "text",
"value": "createDomain(name?)",
"position": {
"start": {
"line": 11,
"column": 4,
"offset": 196
},
"end": {
"line": 11,
"column": 23,
"offset": 215
},
"indent": []
}
}
],
"position": {
"start": {
"line": 11,
"column": 3,
"offset": 195
},
"end": {
"line": 11,
"column": 41,
"offset": 233
},
"indent": []
}
}
],
"position": {
"start": {
"line": 11,
"column": 3,
"offset": 195
},
"end": {
"line": 11,
"column": 41,
"offset": 233
},
"indent": []
}
}
],
"position": {
"start": {
"line": 11,
"column": 1,
"offset": 193
},
"end": {
"line": 11,
"column": 41,
"offset": 233
},
"indent": []
}
},
{
"type": "listItem",
"spread": false,
"checked": null,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"title": null,
"url": "combine.md",
"children": [
{
"type": "text",
"value": "combine(...stores, f)",
"position": {
"start": {
"line": 12,
"column": 4,
"offset": 237
},
"end": {
"line": 12,
"column": 25,
"offset": 258
},
"indent": []
}
}
],
"position": {
"start": {
"line": 12,
"column": 3,
"offset": 236
},
"end": {
"line": 12,
"column": 38,
"offset": 271
},
"indent": []
}
}
],
"position": {
"start": {
"line": 12,
"column": 3,
"offset": 236
},
"end": {
"line": 12,
"column": 38,
"offset": 271
},
"indent": []
}
}
],
"position": {
"start": {
"line": 12,
"column": 1,
"offset": 234
},
"end": {
"line": 12,
"column": 38,
"offset": 271
},
"indent": []
}
},
{
"type": "listItem",
"spread": false,
"checked": null,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"title": null,
"url": "createStoreObject.md",
"children": [
{
"type": "text",
"value": "createStoreObject({storeA, storeB})",
"position": {
"start": {
"line": 13,
"column": 4,
"offset": 275
},
"end": {
"line": 13,
"column": 39,
"offset": 310
},
"indent": []
}
}
],
"position": {
"start": {
"line": 13,
"column": 3,
"offset": 274
},
"end": {
"line": 13,
"column": 62,
"offset": 333
},
"indent": []
}
}
],
"position": {
"start": {
"line": 13,
"column": 3,
"offset": 274
},
"end": {
"line": 13,
"column": 62,
"offset": 333
},
"indent": []
}
}
],
"position": {
"start": {
"line": 13,
"column": 1,
"offset": 272
},
"end": {
"line": 13,
"column": 62,
"offset": 333
},
"indent": []
}
},
{
"type": "listItem",
"spread": false,
"checked": null,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"title": null,
"url": "createApi.md",
"children": [
{
"type": "text",
"value": "createApi(store, api)",
"position": {
"start": {
"line": 14,
"column": 4,
"offset": 337
},
"end": {
"line": 14,
"column": 25,
"offset": 358
},
"indent": []
}
}
],
"position": {
"start": {
"line": 14,
"column": 3,
"offset": 336
},
"end": {
"line": 14,
"column": 40,
"offset": 373
},
"indent": []
}
}
],
"position": {
"start": {
"line": 14,
"column": 3,
"offset": 336
},
"end": {
"line": 14,
"column": 40,
"offset": 373
},
"indent": []
}
}
],
"position": {
"start": {
"line": 14,
"column": 1,
"offset": 334
},
"end": {
"line": 14,
"column": 40,
"offset": 373
},
"indent": []
}
},
{
"type": "listItem",
"spread": false,
"checked": null,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"title": null,
"url": "restore.md",
"children": [
{
"type": "text",
"value": "restore(event, defaultState)",
"position": {
"start": {
"line": 15,
"column": 4,
"offset": 377
},
"end": {
"line": 15,
"column": 32,
"offset": 405
},
"indent": []
}
}
],
"position": {
"start": {
"line": 15,
"column": 3,
"offset": 376
},
"end": {
"line": 15,
"column": 45,
"offset": 418
},
"indent": []
}
}
],
"position": {
"start": {
"line": 15,
"column": 3,
"offset": 376
},
"end": {
"line": 15,
"column": 45,
"offset": 418
},
"indent": []
}
}
],
"position": {
"start": {
"line": 15,
"column": 1,
"offset": 374
},
"end": {
"line": 15,
"column": 45,
"offset": 418
},
"indent": []
}
},
{
"type": "listItem",
"spread": false,
"checked": null,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"title": null,
"url": "restore.md",
"children": [
{
"type": "text",
"value": "restore(effect, defaultState)",
"position": {
"start": {
"line": 16,
"column": 4,
"offset": 422
},
"end": {
"line": 16,
"column": 33,
"offset": 451
},
"indent": []
}
}
],
"position": {
"start": {
"line": 16,
"column": 3,
"offset": 421
},
"end": {
"line": 16,
"column": 46,
"offset": 464
},
"indent": []
}
}
],
"position": {
"start": {
"line": 16,
"column": 3,
"offset": 421
},
"end": {
"line": 16,
"column": 46,
"offset": 464
},
"indent": []
}
}
],
"position": {
"start": {
"line": 16,
"column": 1,
"offset": 419
},
"end": {
"line": 16,
"column": 46,
"offset": 464
},
"indent": []
}
},
{
"type": "listItem",
"spread": false,
"checked": null,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"title": null,
"url": "restore.md",
"children": [
{
"type": "text",
"value": "restore(obj)",
"position": {
"start": {
"line": 17,
"column": 4,
"offset": 468
},
"end": {
"line": 17,
"column": 16,
"offset": 480
},
"indent": []
}
}
],
"position": {
"start": {
"line": 17,
"column": 3,
"offset": 467
},
"end": {
"line": 17,
"column": 29,
"offset": 493
},
"indent": []
}
}
],
"position": {
"start": {
"line": 17,
"column": 3,
"offset": 467
},
"end": {
"line": 17,
"column": 29,
"offset": 493
},
"indent": []
}
}
],
"position": {
"start": {
"line": 17,
"column": 1,
"offset": 465
},
"end": {
"line": 17,
"column": 29,
"offset": 493
},
"indent": []
}
},
{
"type": "listItem",
"spread": false,
"checked": null,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"title": null,
"url": "forward.md",
"children": [
{
"type": "text",
"value": "forward({from, to})",
"position": {
"start": {
"line": 18,
"column": 4,
"offset": 497
},
"end": {
"line": 18,
"column": 23,
"offset": 516
},
"indent": []
}
}
],
"position": {
"start": {
"line": 18,
"column": 3,
"offset": 496
},
"end": {
"line": 18,
"column": 36,
"offset": 529
},
"indent": []
}
}
],
"position": {
"start": {
"line": 18,
"column": 3,
"offset": 496
},
"end": {
"line": 18,
"column": 36,
"offset": 529
},
"indent": []
}
}
],
"position": {
"start": {
"line": 18,
"column": 1,
"offset": 494
},
"end": {
"line": 18,
"column": 36,
"offset": 529
},
"indent": []
}
},
{
"type": "listItem",
"spread": false,
"checked": null,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"title": null,
"url": "fromObservable.md",
"children": [
{
"type": "text",
"value": "fromObservable(observable)",
"position": {
"start": {
"line": 19,
"column": 4,
"offset": 533
},
"end": {
"line": 19,
"column": 30,
"offset": 559
},
"indent": []
}
}
],
"position": {
"start": {
"line": 19,
"column": 3,
"offset": 532
},
"end": {
"line": 19,
"column": 50,
"offset": 579
},
"indent": []
}
}
],
"position": {
"start": {
"line": 19,
"column": 3,
"offset": 532
},
"end": {
"line": 19,
"column": 50,
"offset": 579
},
"indent": []
}
}
],
"position": {
"start": {
"line": 19,
"column": 1,
"offset": 530
},
"end": {
"line": 19,
"column": 50,
"offset": 579
},
"indent": []
}
}
],
"position": {
"start": {
"line": 8,
"column": 1,
"offset": 67
},
"end": {
"line": 19,
"column": 50,
"offset": 579
},
"indent": [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
]
}
},
{
"type": "heading",
"depth": 3,
"children": [
{
"type": "text",
"value": "Event API",
"position": {
"start": {
"line": 21,
"column": 5,
"offset": 585
},
"end": {
"line": 21,
"column": 14,
"offset": 594
},
"indent": []
}
}
],
"position": {
"start": {
"line": 21,
"column": 1,
"offset": 581
},
"end": {
"line": 21,
"column": 14,
"offset": 594
},
"indent": []
}
},
{
"type": "list",
"ordered": false,
"start": null,
"spread": false,
"children": [
{
"type": "listItem",
"spread": false,
"checked": null,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"title": null,
"url": "Event.md",
"children": [
{
"type": "text",
"value": "Event\\<Payload",
"position": {
"start": {
"line": 23,
"column": 4,
"offset": 599
},
"end": {
"line": 23,
"column": 18,
"offset": 613
},
"indent": []
}
},
{
"type": "text",
"value": ">",
"position": {
"start": {
"line": 23,
"column": 18,
"offset": 613
},
"end": {
"line": 23,
"column": 20,
"offset": 615
},
"indent": []
}
}
],
"position": {
"start": {
"line": 23,
"column": 3,
"offset": 598
},
"end": {
"line": 23,
"column": 31,
"offset": 626
},
"indent": []
}
}
],
"position": {
"start": {
"line": 23,
"column": 3,
"offset": 598
},
"end": {
"line": 23,
"column": 31,
"offset": 626
},
"indent": []
}
}
],
"position": {
"start": {
"line": 23,
"column": 1,
"offset": 596
},
"end": {
"line": 23,
"column": 31,
"offset": 626
},
"indent": []
}
}
],
"position": {
"start": {
"line": 23,
"column": 1,
"offset": 596
},
"end": {
"line": 23,
"column": 31,
"offset": 626
},
"indent": []
}
},
{
"type": "heading",
"depth": 3,
"children": [
{
"type": "text",
"value": "Effect API",
"position": {
"start": {
"line": 25,
"column": 5,
"offset": 632
},
"end": {
"line": 25,
"column": 15,
"offset": 642
},
"indent": []
}
}
],
"position": {
"start": {
"line": 25,
"column": 1,
"offset": 628
},
"end": {
"line": 25,
"column": 15,
"offset": 642
},
"indent": []
}
},
{
"type": "list",
"ordered": false,
"start": null,
"spread": false,
"children": [
{
"type": "listItem",
"spread": false,
"checked": null,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"title": null,
"url": "Effect.md",
"children": [
{
"type": "text",
"value": "Effect<Params, Done, Fail>",
"position": {
"start": {
"line": 27,
"column": 4,
"offset": 647
},
"end": {
"line": 27,
"column": 30,
"offset": 673
},
"indent": []
}
}
],
"position": {
"start": {
"line": 27,
"column": 3,
"offset": 646
},
"end": {
"line": 27,
"column": 42,
"offset": 685
},
"indent": []
}
}
],
"position": {
"start": {
"line": 27,
"column": 3,
"offset": 646
},
"end": {
"line": 27,
"column": 42,
"offset": 685
},
"indent": []
}
}
],
"position": {
"start": {
"line": 27,
"column": 1,
"offset": 644
},
"end": {
"line": 27,
"column": 42,
"offset": 685
},
"indent": []
}
}
],
"position": {
"start": {
"line": 27,
"column": 1,
"offset": 644
},
"end": {
"line": 27,
"column": 42,
"offset": 685
},
"indent": []
}
},
{
"type": "heading",
"depth": 3,
"children": [
{
"type": "text",
"value": "Store API",
"position": {
"start": {
"line": 29,
"column": 5,
"offset": 691
},
"end": {
"line": 29,
"column": 14,
"offset": 700
},
"indent": []
}
}
],
"position": {
"start": {
"line": 29,
"column": 1,
"offset": 687
},
"end": {
"line": 29,
"column": 14,
"offset": 700
},
"indent": []
}
},
{
"type": "list",
"ordered": false,
"start": null,
"spread": false,
"children": [
{
"type": "listItem",
"spread": false,
"checked": null,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"title": null,
"url": "Store.md",
"children": [
{
"type": "text",
"value": "Store\\<State",
"position": {
"start": {
"line": 31,
"column": 4,
"offset": 705
},
"end": {
"line": 31,
"column": 16,
"offset": 717
},
"indent": []
}
},
{
"type": "text",
"value": ">",
"position": {
"start": {
"line": 31,
"column": 16,
"offset": 717
},
"end": {
"line": 31,
"column": 18,
"offset": 719
},
"indent": []
}
}
],
"position": {
"start": {
"line": 31,
"column": 3,
"offset": 704
},
"end": {
"line": 31,
"column": 29,
"offset": 730
},
"indent": []
}
}
],
"position": {
"start": {
"line": 31,
"column": 3,
"offset": 704
},
"end": {
"line": 31,
"column": 29,
"offset": 730
},
"indent": []
}
}
],
"position": {
"start": {
"line": 31,
"column": 1,
"offset": 702
},
"end": {
"line": 31,
"column": 29,
"offset": 730
},
"indent": []
}
}
],
"position": {
"start": {
"line": 31,
"column": 1,
"offset": 702
},
"end": {
"line": 31,
"column": 29,
"offset": 730
},
"indent": []
}
},
{
"type": "heading",
"depth": 3,
"children": [
{
"type": "text",
"value": "Domain API",
"position": {
"start": {
"line": 33,
"column": 5,
"offset": 736
},
"end": {
"line": 33,
"column": 15,
"offset": 746
},
"indent": []
}
}
],
"position": {
"start": {
"line": 33,
"column": 1,
"offset": 732
},
"end": {
"line": 33,
"column": 15,
"offset": 746
},
"indent": []
}
},
{
"type": "list",
"ordered": false,
"start": null,
"spread": false,
"children": [
{
"type": "listItem",
"spread": false,
"checked": null,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"title": null,
"url": "Domain.md",
"children": [
{
"type": "text",
"value": "Domain",
"position": {
"start": {
"line": 35,
"column": 4,
"offset": 751
},
"end": {
"line": 35,
"column": 10,
"offset": 757
},
"indent": []
}
}
],
"position": {
"start": {
"line": 35,
"column": 3,
"offset": 750
},
"end": {
"line": 35,
"column": 22,
"offset": 769
},
"indent": []
}
}
],
"position": {
"start": {
"line": 35,
"column": 3,
"offset": 750
},
"end": {
"line": 35,
"column": 22,
"offset": 769
},
"indent": []
}
}
],
"position": {
"start": {
"line": 35,
"column": 1,
"offset": 748
},
"end": {
"line": 35,
"column": 22,
"offset": 769
},
"indent": []
}
}
],
"position": {
"start": {
"line": 35,
"column": 1,
"offset": 748
},
"end": {
"line": 35,
"column": 22,
"offset": 769
},
"indent": []
}
},
{
"type": "thematicBreak",
"position": {
"start": {
"line": 38,
"column": 1,
"offset": 772
},
"end": {
"line": 38,
"column": 4,
"offset": 775
},
"indent": []
}
},
{
"type": "paragraph",
"children": [
{
"type": "text",
"value": "id: createStore\ntitle: createStore",
"position": {
"start": {
"line": 39,
"column": 1,
"offset": 776
},
"end": {
"line": 40,
"column": 19,
"offset": 810
},
"indent": [
1
]
}
}
],
"position": {
"start": {
"line": 39,
"column": 1,
"offset": 776
},
"end": {
"line": 40,
"column": 19,
"offset": 810
},
"indent": [
1
]
}
},
{
"type": "heading",
"depth": 2,
"children": [
{
"type": "text",
"value": "hide_title: true",
"position": {
"start": {
"line": 41,
"column": 1,
"offset": 811
},
"end": {
"line": 41,
"column": 17,
"offset": 827
},
"indent": []
}
}
],
"position": {
"start": {
"line": 41,
"column": 1,
"offset": 811
},
"end": {
"line": 42,
"column": 4,
"offset": 831
},
"indent": [
1
]
}
},
{
"type": "heading",
"depth": 1,
"children": [
{
"type": "inlineCode",
"value": "createStore(defaultState)",
"position": {
"start": {
"line": 44,
"column": 3,
"offset": 835
},
"end": {
"line": 44,
"column": 30,
"offset": 862
},
"indent": []
}
}
],
"position": {
"start": {
"line": 44,
"column": 1,
"offset": 833
},
"end": {
"line": 44,
"column": 30,
"offset": 862
},
"indent": []
}
},
{
"type": "paragraph",
"children": [
{
"type": "text",
"value": "Creates a ",
"position": {
"start": {
"line": 46,
"column": 1,
"offset": 864
},
"end": {
"line": 46,
"column": 11,
"offset": 874
},
"indent": []
}
},
{
"type": "link",
"title": null,
"url": "Store.md",
"children": [
{
"type": "text",
"value": "store",
"position": {
"start": {
"line": 46,
"column": 12,
"offset": 875
},
"end": {
"line": 46,
"column": 17,
"offset": 880
},
"indent": []
}
}
],
"position": {
"start": {
"line": 46,
"column": 11,
"offset": 874
},
"end": {
"line": 46,
"column": 28,
"offset": 891
},
"indent": []
}
},
{
"type": "text",
"value": ".",
"position": {
"start": {
"line": 46,
"column": 28,
"offset": 891
},
"end": {
"line": 46,
"column": 29,
"offset": 892
},
"indent": []
}
}
],
"position": {
"start": {
"line": 46,
"column": 1,
"offset": 864
},
"end": {
"line": 46,
"column": 29,
"offset": 892
},
"indent": []
}
},
{
"type": "heading",
"depth": 4,
"children": [
{
"type": "text",
"value": "Arguments",
"position": {
"start": {
"line": 48,
"column": 6,
"offset": 899
},
"end": {
"line": 48,
"column": 15,
"offset": 908
},
"indent": []
}
}
],
"position": {
"start": {
"line": 48,
"column": 1,
"offset": 894
},
"end": {
"line": 48,
"column": 15,
"offset": 908
},
"indent": []
}
},
{
"type": "list",
"ordered": true,
"start": 1,
"spread": false,
"children": [
{
"type": "listItem",
"spread": false,
"checked": null,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "inlineCode",
"value": "defaultState",
"position": {
"start": {
"line": 50,
"column": 4,
"offset": 913
},
"end": {
"line": 50,
"column": 18,
"offset": 927
},
"indent": []
}
},
{
"type": "text",
"value": " (",
"position": {
"start": {
"line": 50,
"column": 18,
"offset": 927
},
"end": {
"line": 50,
"column": 20,
"offset": 929
},
"indent": []
}
},
{
"type": "emphasis",
"children": [
{
"type": "text",
"value": "State",
"position": {
"start": {
"line": 50,
"column": 21,
"offset": 930
},
"end": {
"line": 50,
"column": 26,
"offset": 935
},
"indent": []
}
}
],
"position": {
"start": {
"line": 50,
"column": 20,
"offset": 929
},
"end": {
"line": 50,
"column": 27,
"offset": 936
},
"indent": []
}
},
{
"type": "text",
"value": "): Default state",
"position": {
"start": {
"line": 50,
"column": 27,
"offset": 936
},
"end": {
"line": 50,
"column": 43,
"offset": 952
},
"indent": []
}
}
],
"position": {
"start": {
"line": 50,
"column": 4,
"offset": 913
},
"end": {
"line": 50,
"column": 43,
"offset": 952
},
"indent": []
}
}
],
"position": {
"start": {
"line": 50,
"column": 1,
"offset": 910
},
"end": {
"line": 50,
"column": 43,
"offset": 952
},
"indent": []
}
}
],
"position": {
"start": {
"line": 50,
"column": 1,
"offset": 910
},
"end": {
"line": 50,
"column": 43,
"offset": 952
},
"indent": []
}
},
{
"type": "heading",
"depth": 4,
"children": [
{
"type": "text",
"value": "Returns",
"position": {
"start": {
"line": 52,
"column": 6,
"offset": 959
},
"end": {
"line": 52,
"column": 13,
"offset": 966
},
"indent": []
}
}
],
"position": {
"start": {
"line": 52,
"column": 1,
"offset": 954
},
"end": {
"line": 52,
"column": 13,
"offset": 966
},
"indent": []
}
},
{
"type": "paragraph",
"children": [
{
"type": "text",
"value": "(",
"position": {
"start": {
"line": 54,
"column": 1,
"offset": 968
},
"end": {
"line": 54,
"column": 2,
"offset": 969
},
"indent": []
}
},
{
"type": "link",
"title": null,
"url": "Store.md",
"children": [
{
"type": "emphasis",
"children": [
{
"type": "inlineCode",
"value": "Store",
"position": {
"start": {
"line": 54,
"column": 4,
"offset": 971
},
"end": {
"line": 54,
"column": 11,
"offset": 978
},
"indent": []
}
}
],
"position": {
"start": {
"line": 54,
"column": 3,
"offset": 970
},
"end": {
"line": 54,
"column": 12,
"offset": 979
},
"indent": []
}
}
],
"position": {
"start": {
"line": 54,
"column": 2,
"offset": 969
},
"end": {
"line": 54,
"column": 23,
"offset": 990
},
"indent": []
}
},
{
"type": "text",
"value": "): An object that holds the state tree. There can be multiple stores.",
"position": {
"start": {
"line": 54,
"column": 23,
"offset": 990
},
"end": {
"line": 54,
"column": 92,
"offset": 1059
},
"indent": []
}
}
],
"position": {
"start": {
"line": 54,
"column": 1,
"offset": 968
},
"end": {
"line": 54,
"column": 92,
"offset": 1059
},
"indent": []
}
},
{
"type": "heading",
"depth": 4,
"children": [
{
"type": "text",
"value": "Example",
"position": {
"start": {
"line": 56,
"column": 6,
"offset": 1066
},
"end": {
"line": 56,
"column": 13,
"offset": 1073
},
"indent": []
}
}
],
"position": {
"start": {
"line": 56,
"column": 1,
"offset": 1061
},
"end": {
"line": 56,
"column": 13,
"offset": 1073
},
"indent": []
}
},
{
"type": "code",
"lang": "js",
"meta": null,
"value": "// Create events\nconst addTodo = createEvent()\nconst clearTodos = createEvent()\n\n// Create store\nconst todos = createStore([]) // <-- Default state\n\ntodos\n // Add reducer\n .on(addTodo, (state, todo) => [...state, todo])\n // Will reset store to default state when clearTodos is fired\n .reset(clearTodos)\n\n// Create derived store\nconst selectedTodos = todos.map(todos => {\n // Filter array inside store\n return todos.filter(todo => !!todo.selected)\n})\n\n// Handle side effects\ntodos.watch(state => console.log(state))",
"position": {
"start": {
"line": 58,
"column": 1,
"offset": 1075
},
"end": {
"line": 80,
"column": 4,
"offset": 1605
},
"indent": [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
]
}
},
{
"type": "thematicBreak",
"position": {
"start": {
"line": 83,
"column": 1,
"offset": 1608
},
"end": {
"line": 83,
"column": 4,
"offset": 1611
},
"indent": []
}
},
{
"type": "paragraph",
"children": [
{
"type": "text",
"value": "id: createEvent\ntitle: createEvent",
"position": {
"start": {
"line": 84,
"column": 1,
"offset": 1612
},
"end": {
"line": 85,
"column": 19,
"offset": 1646
},
"indent": [
1
]
}
}
],
"position": {
"start": {
"line": 84,
"column": 1,
"offset": 1612
},
"end": {
"line": 85,
"column": 19,
"offset": 1646
},
"indent": [
1
]
}
},
{
"type": "heading",
"depth": 2,
"children": [
{
"type": "text",
"value": "hide_title: true",
"position": {
"start": {
"line": 86,
"column": 1,
"offset": 1647
},
"end": {
"line": 86,
"column": 17,
"offset": 1663
},
"indent": []
}
}
],
"position": {
"start": {
"line": 86,
"column": 1,
"offset": 1647
},
"end": {
"line": 87,
"column": 4,
"offset": 1667
},
"indent": [
1
]
}
},
{
"type": "heading",
"depth": 1,
"children": [
{
"type": "inlineCode",
"value": "createEvent(name?)",
"position": {
"start": {
"line": 89,
"column": 3,
"offset": 1671
},
"end": {
"line": 89,
"column": 23,
"offset": 1691
},
"indent": []
}
}
],
"position": {
"start": {
"line": 89,
"column": 1,
"offset": 1669
},
"end": {
"line": 89,
"column": 23,
"offset": 1691
},
"indent": []
}
},
{
"type": "paragraph",
"children": [
{
"type": "text",
"value": "Creates an ",
"position": {
"start": {
"line": 91,
"column": 1,
"offset": 1693
},
"end": {
"line": 91,
"column": 12,
"offset": 1704
},
"indent": []
}
},
{
"type": "link",
"title": null,
"url": "Event.md",
"children": [
{
"type": "text",
"value": "event",
"position": {
"start": {
"line": 91,
"column": 13,
"offset": 1705
},
"end": {
"line": 91,
"column": 18,
"offset": 1710
},
"indent": []
}
}
],
"position": {
"start": {
"line": 91,
"column": 12,
"offset": 1704
},
"end": {
"line": 91,
"column": 29,
"offset": 1721
},
"indent": []
}
}
],
"position": {
"start": {
"line": 91,
"column": 1,
"offset": 1693
},
"end": {
"line": 91,
"column": 29,
"offset": 1721
},
"indent": []
}
},
{
"type": "heading",
"depth": 4,
"children": [
{
"type": "text",
"value": "Arguments",
"position": {
"start": {
"line": 93,
"column": 6,
"offset": 1728
},
"end": {
"line": 93,
"column": 15,
"offset": 1737
},
"indent": []
}
}
],
"position": {
"start": {
"line": 93,
"column": 1,
"offset": 1723
},
"end": {
"line": 93,
"column": 15,
"offset": 1737
},
"indent": []
}
},
{
"type": "list",
"ordered": true,
"start": 1,
"spread": false,
"children": [
{
"type": "listItem",
"spread": false,
"checked": null,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "inlineCode",
"value": "name",
"position": {
"start": {
"line": 95,
"column": 4,
"offset": 1742
},
"end": {
"line": 95,
"column": 10,
"offset": 1748
},
"indent": []
}
},
{
"type": "text",
"value": "? ",
"position": {
"start": {
"line": 95,
"column": 10,
"offset": 1748
},
"end": {
"line": 95,
"column": 12,
"offset": 1750
},
"indent": []
}
},
{
"type": "emphasis",
"children": [
{
"type": "text",
"value": "(string)",
"position": {
"start": {
"line": 95,
"column": 13,
"offset": 1751
},
"end": {
"line": 95,
"column": 21,
"offset": 1759
},
"indent": []
}
}
],
"position": {
"start": {
"line": 95,
"column": 12,
"offset": 1750
},
"end": {
"line": 95,
"column": 22,
"offset": 1760
},
"indent": []
}
},
{
"type": "text",
"value": ": ",
"position": {
"start": {
"line": 95,
"column": 22,
"offset": 1760
},
"end": {
"line": 95,
"column": 24,
"offset": 1762
},
"indent": []
}
},
{
"type": "link",
"title": null,
"url": "Event.md",
"children": [
{
"type": "text",
"value": "Event",
"position": {
"start": {
"line": 95,
"column": 25,
"offset": 1763
},
"end": {
"line": 95,
"column": 30,
"offset": 1768
},
"indent": []
}
}
],
"position": {
"start": {
"line": 95,
"column": 24,
"offset": 1762
},
"end": {
"line": 95,
"column": 41,
"offset": 1779
},
"indent": []
}
},
{
"type": "text",
"value": " name",
"position": {
"start": {
"line": 95,
"column": 41,
"offset": 1779
},
"end": {
"line": 95,
"column": 46,
"offset": 1784
},
"indent": []
}
}
],
"position": {
"start": {
"line": 95,
"column": 4,
"offset": 1742
},
"end": {
"line": 95,
"column": 46,
"offset": 1784
},
"indent": []
}
}
],
"position": {
"start": {
"line": 95,
"column": 1,
"offset": 1739
},
"end": {
"line": 95,
"column": 46,
"offset": 1784
},
"indent": []
}
}
],
"position": {
"start": {
"line": 95,
"column": 1,
"offset": 1739
},
"end": {
"line": 95,
"column": 46,
"offset": 1784
},
"indent": []
}
},
{
"type": "heading",
"depth": 4,
"children": [
{
"type": "text",
"value": "Returns",
"position": {
"start": {
"line": 97,
"column": 6,
"offset": 1791
},
"end": {
"line": 97,
"column": 13,
"offset": 1798
},
"indent": []
}
}
],
"position": {
"start": {
"line": 97,
"column": 1,
"offset": 1786
},
"end": {
"line": 97,
"column": 13,
"offset": 1798
},
"indent": []
}
},
{
"type": "paragraph",
"children": [
{
"type": "text",
"value": "(",
"position": {
"start": {
"line": 99,
"column": 1,
"offset": 1800
},
"end": {
"line": 99,
"column": 2,
"offset": 1801
},
"indent": []
}
},
{
"type": "link",
"title": null,
"url": "Event.md",
"children": [
{
"type": "emphasis",
"children": [
{
"type": "inlineCode",
"value": "Event",
"position": {
"start": {
"line": 99,
"column": 4,
"offset": 1803
},
"end": {
"line": 99,
"column": 11,
"offset": 1810
},
"indent": []
}
}
],
"position": {
"start": {
"line": 99,
"column": 3,
"offset": 1802
},
"end": {
"line": 99,
"column": 12,
"offset": 1811
},
"indent": []
}
}
],
"position": {
"start": {
"line": 99,
"column": 2,
"offset": 1801
},
"end": {
"line": 99,
"column": 23,
"offset": 1822
},
"indent": []
}
},
{
"type": "text",
"value": "): An intention to change state.",
"position": {
"start": {
"line": 99,
"column": 23,
"offset": 1822
},
"end": {
"line": 99,
"column": 55,
"offset": 1854
},
"indent": []
}
}
],
"position": {
"start": {
"line": 99,
"column": 1,
"offset": 1800
},
"end": {
"line": 99,
"column": 55,
"offset": 1854
},
"indent": []
}
},
{
"type": "heading",
"depth": 4,
"children": [
{
"type": "text",
"value": "Example",
"position": {
"start": {
"line": 101,
"column": 6,
"offset": 1861
},
"end": {
"line": 101,
"column": 13,
"offset": 1868
},
"indent": []
}
}
],
"position": {
"start": {
"line": 101,
"column": 1,
"offset": 1856
},
"end": {
"line": 101,
"column": 13,
"offset": 1868
},
"indent": []
}
},
{
"type": "code",
"lang": "js",
"meta": null,
"value": "const event = createEvent() // unnamed event\nconst onMessage = createEvent('message')\n\nconst socket = new WebSocket('wss://example.com:4000')\nsocket.onmessage = msg => onMessage(msg)\n\nconst data = onMessage.map(msg => msg.data).map(JSON.parse)\n\n// Handle side effects\ndata.watch(console.log)",
"position": {
"start": {
"line": 103,
"column": 1,
"offset": 1870
},
"end": {
"line": 114,
"column": 4,
"offset": 2171
},
"indent": [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
]
}
},
{
"type": "thematicBreak",
"position": {
"start": {
"line": 117,
"column": 1,
"offset": 2174
},
"end": {
"line": 117,
"column": 4,
"offset": 2177
},
"indent": []
}
},
{
"type": "paragraph",
"children": [
{
"type": "text",
"value": "id: createEffect\ntitle: createEffect",
"position": {
"start": {
"line": 118,
"column": 1,
"offset": 2178
},
"end": {
"line": 119,
"column": 20,
"offset": 2214
},
"indent": [
1
]
}
}
],
"position": {
"start": {
"line": 118,
"column": 1,
"offset": 2178
},
"end": {
"line": 119,
"column": 20,
"offset": 2214
},
"indent": [
1
]
}
},
{
"type": "heading",
"depth": 2,
"children": [
{
"type": "text",
"value": "hide_title: true",
"position": {
"start": {
"line": 120,
"column": 1,
"offset": 2215
},
"end": {
"line": 120,
"column": 17,
"offset": 2231
},
"indent": []
}
}
],
"position": {
"start": {
"line": 120,
"column": 1,
"offset": 2215
},
"end": {
"line": 121,
"column": 4,
"offset": 2235
},
"indent": [
1
]
}
},
{
"type": "heading",
"depth": 1,
"children": [
{
"type": "inlineCode",
"value": "createEffect(name?)",
"position": {
"start": {
"line": 123,
"column": 3,
"offset": 2239
},
"end": {
"line": 123,
"column": 24,
"offset": 2260
},
"indent": []
}
}
],
"position": {
"start": {
"line": 123,
"column": 1,
"offset": 2237
},
"end": {
"line": 123,
"column": 24,
"offset": 2260
},
"indent": []
}
},
{
"type": "paragraph",
"children": [
{
"type": "text",
"value": "Creates an ",
"position": {
"start": {
"line": 125,
"column": 1,
"offset": 2262
},
"end": {
"line": 125,
"column": 12,
"offset": 2273
},
"indent": []
}
},
{
"type": "link",
"title": null,
"url": "Effect.md",
"children": [
{
"type": "text",
"value": "effect",
"position": {
"start": {
"line": 125,
"column": 13,
"offset": 2274
},
"end": {
"line": 125,
"column": 19,
"offset": 2280
},
"indent": []
}
}
],
"position": {
"start": {
"line": 125,
"column": 12,
"offset": 2273
},
"end": {
"line": 125,
"column": 31,
"offset": 2292
},
"indent": []
}
}
],
"position": {
"start": {
"line": 125,
"column": 1,
"offset": 2262
},
"end": {
"line": 125,
"column": 31,
"offset": 2292
},
"indent": []
}
},
{
"type": "heading",
"depth": 4,
"children": [
{
"type": "text",
"value": "Arguments",
"position": {
"start": {
"line": 127,
"column": 6,
"offset": 2299
},
"end": {
"line": 127,
"column": 15,
"offset": 2308
},
"indent": []
}
}
],
"position": {
"start": {
"line": 127,
"column": 1,
"offset": 2294
},
"end": {
"line": 127,
"column": 15,
"offset": 2308
},
"indent": []
}
},
{
"type": "list",
"ordered": true,
"start": 1,
"spread": false,
"children": [
{
"type": "listItem",
"spread": false,
"checked": null,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "inlineCode",
"value": "name",
"position": {
"start": {
"line": 129,
"column": 4,
"offset": 2313
},
"end": {
"line": 129,
"column": 10,
"offset": 2319
},
"indent": []
}
},
{
"type": "text",
"value": "? ",
"position": {
"start": {
"line": 129,
"column": 10,
"offset": 2319
},
"end": {
"line": 129,
"column": 12,
"offset": 2321
},
"indent": []
}
},
{
"type": "emphasis",
"children": [
{
"type": "text",
"value": "(string)",
"position": {
"start": {
"line": 129,
"column": 13,
"offset": 2322
},
"end": {
"line": 129,
"column": 21,
"offset": 2330
},
"indent": []
}
}
],
"position": {
"start": {
"line": 129,
"column": 12,
"offset": 2321
},
"end": {
"line": 129,
"column": 22,
"offset": 2331
},
"indent": []
}
},
{
"type": "text",
"value": ": ",
"position": {
"start": {
"line": 129,
"column": 22,
"offset": 2331
},
"end": {
"line": 129,
"column": 24,
"offset": 2333
},
"indent": []
}
},
{
"type": "link",
"title": null,
"url": "Effect.md",
"children": [
{
"type": "text",
"value": "Effect",
"position": {
"start": {
"line": 129,
"column": 25,
"offset": 2334
},
"end": {
"line": 129,
"column": 31,
"offset": 2340
},
"indent": []
}
}
],
"position": {
"start": {
"line": 129,
"column": 24,
"offset": 2333
},
"end": {
"line": 129,
"column": 43,
"offset": 2352
},
"indent": []
}
},
{
"type": "text",
"value": " name",
"position": {
"start": {
"line": 129,
"column": 43,
"offset": 2352
},
"end": {
"line": 129,
"column": 48,
"offset": 2357
},
"indent": []
}
}
],
"position": {
"start": {
"line": 129,
"column": 4,
"offset": 2313
},
"end": {
"line": 129,
"column": 48,
"offset": 2357
},
"indent": []
}
}
],
"position": {
"start": {
"line": 129,
"column": 1,
"offset": 2310
},
"end": {
"line": 129,
"column": 48,
"offset": 2357
},
"indent": []
}
},
{
"type": "listItem",
"spread": false,
"checked": null,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "inlineCode",
"value": "params",
"position": {
"start": {
"line": 130,
"column": 4,
"offset": 2361
},
"end": {
"line": 130,
"column": 12,
"offset": 2369
},
"indent": []
}
},
{
"type": "text",
"value": "? (",
"position": {
"start": {
"line": 130,
"column": 12,
"offset": 2369
},
"end": {
"line": 130,
"column": 15,
"offset": 2372
},
"indent": []
}
},
{
"type": "emphasis",
"children": [
{
"type": "text",
"value": "Params",
"position": {
"start": {
"line": 130,
"column": 16,
"offset": 2373
},
"end": {
"line": 130,
"column": 22,
"offset": 2379
},
"indent": []
}
}
],
"position": {
"start": {
"line": 130,
"column": 15,
"offset": 2372
},
"end": {
"line": 130,
"column": 23,
"offset": 2380
},
"indent": []
}
},
{
"type": "text",
"value": "): Setup effect",
"position": {
"start": {
"line": 130,
"column": 23,
"offset": 2380
},
"end": {
"line": 130,
"column": 38,
"offset": 2395
},
"indent": []
}
}
],
"position": {
"start": {
"line": 130,
"column": 4,
"offset": 2361
},
"end": {
"line": 130,
"column": 38,
"offset": 2395
},
"indent": []
}
},
{
"type": "list",
"ordered": false,
"start": null,
"spread": false,
"children": [
{
"type": "listItem",
"spread": false,
"checked": null,
"children": [
{
"type": "paragraph",
"children": [
{
"type": "inlineCode",
"value": "handler",
"position": {
"start": {
"line": 131,
"column": 7,
"offset": 2402
},
"end": {
"line": 131,
"column": 16,
"offset": 2411
},
"indent": []
}
},
{
"type": "text",
"value": " (",
"position": {
"start": {
"line": 131,
"column": 16,
"offset": 2411
},
"end": {
"line": 131,
"column": 18,
"offset": 2413
},
"indent": []
}
},
{
"type": "emphasis",
"children": [
{
"type": "text",
"value": "Function",
"position": {
"start": {
"line": 131,
"column": 19,
"offset": 2414
},
"end": {
"line": 131,
"column": 27,
"offset": 2422
},
"indent": []
}
}
],
"position": {
"start": {
"line": 131,
"column": 18,
"offset": 2413
},
"end": {
"line": 131,
"column": 28,
"offset": 2423
},
"indent": []
}
},
{
"type": "text",
"value": "): thunk to handle effect calls, also can be set with ",
"position": {
"start": {
"line": 131,
"column": 28,
"offset": 2423
},
"end": {
"line": 131,
"column": 82,
"offset": 2477
},
"indent": []
}
},
{
"type": "link",
"title": null,
"url": "#use",
"children": [
{
"type": "inlineCode",
"value": "use(thunk)",
"position": {
"start": {
"line": 131,
"column": 83,
"offset": 2478
},
"end": {
"line": 131,
"column": 95,
"offset": 2490
},
"indent": []
}
}
],
"position": {
"start": {
"line": 131,
"column": 82,
"offset": 2477
},
"end": {
"line": 131,
"column": 102,
"offset": 2497
},
"indent": []
}
}
],
"position": {
"start": {
"line": 131,
"column": 7,
"offset": 2402
},
"end": {
"line": 131,
"column": 102,
"offset": 2497
},
"indent": []
}
}
],
"position": {
"start": {
"line": 131,
"column": 5,
"offset": 2400
},
"end": {
"line": 131,
"column": 102,
"offset": 2497
},
"indent": []
}
}
],
"position": {
"start": {
"line": 131,
"column": 5,
"offset": 2400
},
"end": {
"line": 131,
"column": 102,
"offset": 2497
},
"indent": []
}
}
],
"position": {
"start": {
"line": 130,
"column": 1,
"offset": 2358
},
"end": {
"line": 131,
"column": 102,
"offset": 2497
},
"indent": [
1
]
}
}
],
"position": {
"start": {
"line": 129,
"column": 1,
"offset": 2310
},
"end": {
"line": 131,
"column": 102,
"offset": 2497
},
"indent": [
1,
1
]
}
},
{
"type": "heading",
"depth": 4,
"children": [
{
"type": "text",
"value": "Returns",
"position": {
"start": {
"line": 133,
"column": 6,
"offset": 2504
},
"end": {
"line": 133,
"column": 13,
"offset": 2511
},
"indent": []
}
}
],
"position": {
"start": {
"line": 133,
"column": 1,
"offset": 2499
},
"end": {
"line": 133,
"column": 13,
"offset": 2511
},
"indent": []
}
},
{
"type": "paragraph",
"children": [
{
"type": "text",
"value": "(",
"position": {
"start": {
"line": 135,
"column": 1,
"offset": 2513
},
"end": {
"line": 135,
"column": 2,
"offset": 2514
},
"indent": []
}
},
{
"type": "link",
"title": null,
"url": "Effect.md",
"children": [
{
"type": "emphasis",
"children": [
{
"type": "inlineCode",
"value": "Effect",
"position": {
"start": {
"line": 135,
"column": 4,
"offset": 2516
},
"end": {
"line": 135,
"column": 12,
"offset": 2524
},
"indent": []
}
}
],
"position": {
"start": {
"line": 135,
"column": 3,
"offset": 2515
},
"end": {
"line": 135,
"column": 13,
"offset": 2525
},
"indent": []
}
}
],
"position": {
"start": {
"line": 135,
"column": 2,
"offset": 2514
},
"end": {
"line": 135,
"column": 25,
"offset": 2537
},
"indent": []
}
},
{
"type": "text",
"value": "): A container for async function.",
"position": {
"start": {
"line": 135,
"column": 25,
"offset": 2537
},
"end": {
"line": 135,
"column": 59,
"offset": 2571
},
"indent": []
}
}
],
"position": {
"start": {
"line": 135,
"column": 1,
"offset": 2513
},
"end": {
"line": 135,
"column": 59,
"offset": 2571
},
"indent": []
}
},
{
"type": "heading",
"depth": 4,
"children": [
{
"type": "text",
"value": "Example",
"position": {
"start": {
"line": 137,
"column": 6,
"offset": 2578
},
"end": {
"line": 137,
"column": 13,
"offset": 2585
},
"indent": []
}
}
],
"position": {
"start": {
"line": 137,
"column": 1,
"offset": 2573
},
"end": {
"line": 137,
"column": 13,
"offset": 2585
},
"indent": []
}
},
{
"type": "code",
"lang": "js",
"meta": null,
"value": "const getUser = createEffect('get user', {\n handler: params => fetch(`https://example.com/get-user/${params.id}`)\n .then(res => res.json())\n})\n\n// OR\ngetUser.use(params => {\n return fetch(`https://example.com/get-user/${params.id}`)\n .then(res => res.json())\n})\n\nconst users = createStore([]) // <-- Default state\n // add reducer for getUser.done event (fires when promise resolved)\n .on(getUser.done, (state, {result: user, params}) => [...state, user])\n\n// subscribe to promise resolve\ngetUser.done.watch(({result, params}) => {\n console.log(params) // {id: 1}\n console.log(result) // resolved value\n})\n\n// subscribe to promise reject (or throw)\ngetUser.fail.watch(({error, params}) => {\n console.error(params) // {id: 1}\n console.error(error) // rejected value\n})\n\n// you can replace function anytime\ngetUser.use(() => promiseMock)\n\n// call effect with your params\ngetUser({id: 1})\n\nconst data = await getUser({id: 2}) // handle promise",
"position": {
"start": {
"line": 139,
"column": 1,
"offset": 2587
},
"end": {
"line": 174,
"column": 4,
"offset": 3550
},
"indent": [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
]
}
}
],
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 175,
"column": 1,
"offset": 3551
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment