diff --git a/docs/assets/js/search.js b/docs/assets/js/search.js index 21c56b3..8281e4e 100644 --- a/docs/assets/js/search.js +++ b/docs/assets/js/search.js @@ -1,3 +1,3 @@ var typedoc = typedoc || {}; typedoc.search = typedoc.search || {}; - typedoc.search.data = {"kinds":{"1":"External module","64":"Function","128":"Class","512":"Constructor","1024":"Property","2048":"Method","65536":"Type literal","4194304":"Type alias"},"rows":[{"id":0,"kind":1,"name":"\"Task\"","url":"modules/_task_.html","classes":"tsd-kind-external-module"},{"id":1,"kind":128,"name":"Task","url":"classes/_task_.task.html","classes":"tsd-kind-class tsd-parent-kind-external-module tsd-has-type-parameter","parent":"\"Task\""},{"id":2,"kind":2048,"name":"succeed","url":"classes/_task_.task.html#succeed","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"\"Task\".Task"},{"id":3,"kind":2048,"name":"fail","url":"classes/_task_.task.html#fail","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"\"Task\".Task"},{"id":4,"kind":2048,"name":"fromPromise","url":"classes/_task_.task.html#frompromise","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"\"Task\".Task"},{"id":5,"kind":2048,"name":"all","url":"classes/_task_.task.html#all","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"\"Task\".Task"},{"id":6,"kind":2048,"name":"race","url":"classes/_task_.task.html#race","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"\"Task\".Task"},{"id":7,"kind":2048,"name":"loop","url":"classes/_task_.task.html#loop","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"\"Task\".Task"},{"id":8,"kind":1024,"name":"fn","url":"classes/_task_.task.html#fn","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-private","parent":"\"Task\".Task"},{"id":9,"kind":512,"name":"constructor","url":"classes/_task_.task.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"\"Task\".Task"},{"id":10,"kind":2048,"name":"fork","url":"classes/_task_.task.html#fork","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"Task\".Task"},{"id":11,"kind":2048,"name":"map","url":"classes/_task_.task.html#map","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"\"Task\".Task"},{"id":12,"kind":2048,"name":"andThen","url":"classes/_task_.task.html#andthen","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"\"Task\".Task"},{"id":13,"kind":2048,"name":"andThenP","url":"classes/_task_.task.html#andthenp","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"\"Task\".Task"},{"id":14,"kind":2048,"name":"orElse","url":"classes/_task_.task.html#orelse","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"\"Task\".Task"},{"id":15,"kind":2048,"name":"mapError","url":"classes/_task_.task.html#maperror","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"\"Task\".Task"},{"id":16,"kind":2048,"name":"assign","url":"classes/_task_.task.html#assign","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"\"Task\".Task"},{"id":17,"kind":2048,"name":"do","url":"classes/_task_.task.html#do","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"Task\".Task"},{"id":18,"kind":4194304,"name":"Reject","url":"modules/_task_.html#reject","classes":"tsd-kind-type-alias tsd-parent-kind-external-module tsd-has-type-parameter","parent":"\"Task\""},{"id":19,"kind":65536,"name":"__type","url":"modules/_task_.html#reject.__type-2","classes":"tsd-kind-type-literal tsd-parent-kind-type-alias tsd-is-not-exported","parent":"\"Task\".Reject"},{"id":20,"kind":4194304,"name":"Resolve","url":"modules/_task_.html#resolve","classes":"tsd-kind-type-alias tsd-parent-kind-external-module tsd-has-type-parameter","parent":"\"Task\""},{"id":21,"kind":65536,"name":"__type","url":"modules/_task_.html#resolve.__type-3","classes":"tsd-kind-type-literal tsd-parent-kind-type-alias tsd-is-not-exported","parent":"\"Task\".Resolve"},{"id":22,"kind":4194304,"name":"Cancel","url":"modules/_task_.html#cancel","classes":"tsd-kind-type-alias tsd-parent-kind-external-module","parent":"\"Task\""},{"id":23,"kind":65536,"name":"__type","url":"modules/_task_.html#cancel.__type","classes":"tsd-kind-type-literal tsd-parent-kind-type-alias tsd-is-not-exported","parent":"\"Task\".Cancel"},{"id":24,"kind":4194304,"name":"Computation","url":"modules/_task_.html#computation","classes":"tsd-kind-type-alias tsd-parent-kind-external-module tsd-has-type-parameter","parent":"\"Task\""},{"id":25,"kind":65536,"name":"__type","url":"modules/_task_.html#computation.__type-1","classes":"tsd-kind-type-literal tsd-parent-kind-type-alias tsd-is-not-exported","parent":"\"Task\".Computation"},{"id":26,"kind":64,"name":"noop","url":"modules/_task_.html#noop","classes":"tsd-kind-function tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"Task\""},{"id":27,"kind":1,"name":"\"index\"","url":"modules/_index_.html","classes":"tsd-kind-external-module"}]}; \ No newline at end of file + typedoc.search.data = {"kinds":{"1":"External module","64":"Function","128":"Class","512":"Constructor","1024":"Property","2048":"Method","65536":"Type literal","4194304":"Type alias"},"rows":[{"id":0,"kind":1,"name":"\"Task\"","url":"modules/_task_.html","classes":"tsd-kind-external-module"},{"id":1,"kind":128,"name":"Task","url":"classes/_task_.task.html","classes":"tsd-kind-class tsd-parent-kind-external-module tsd-has-type-parameter","parent":"\"Task\""},{"id":2,"kind":2048,"name":"succeed","url":"classes/_task_.task.html#succeed","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"\"Task\".Task"},{"id":3,"kind":2048,"name":"fail","url":"classes/_task_.task.html#fail","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"\"Task\".Task"},{"id":4,"kind":2048,"name":"fromPromise","url":"classes/_task_.task.html#frompromise","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"\"Task\".Task"},{"id":5,"kind":2048,"name":"all","url":"classes/_task_.task.html#all","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"\"Task\".Task"},{"id":6,"kind":2048,"name":"race","url":"classes/_task_.task.html#race","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"\"Task\".Task"},{"id":7,"kind":2048,"name":"loop","url":"classes/_task_.task.html#loop","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"\"Task\".Task"},{"id":8,"kind":2048,"name":"run","url":"classes/_task_.task.html#run","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"\"Task\".Task"},{"id":9,"kind":1024,"name":"fn","url":"classes/_task_.task.html#fn","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-private","parent":"\"Task\".Task"},{"id":10,"kind":512,"name":"constructor","url":"classes/_task_.task.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"\"Task\".Task"},{"id":11,"kind":2048,"name":"fork","url":"classes/_task_.task.html#fork","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"Task\".Task"},{"id":12,"kind":2048,"name":"resolve","url":"classes/_task_.task.html#resolve","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"Task\".Task"},{"id":13,"kind":2048,"name":"map","url":"classes/_task_.task.html#map","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"\"Task\".Task"},{"id":14,"kind":2048,"name":"andThen","url":"classes/_task_.task.html#andthen","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"\"Task\".Task"},{"id":15,"kind":2048,"name":"andThenP","url":"classes/_task_.task.html#andthenp","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"\"Task\".Task"},{"id":16,"kind":2048,"name":"orElse","url":"classes/_task_.task.html#orelse","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"\"Task\".Task"},{"id":17,"kind":2048,"name":"mapError","url":"classes/_task_.task.html#maperror","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"\"Task\".Task"},{"id":18,"kind":2048,"name":"assign","url":"classes/_task_.task.html#assign","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"\"Task\".Task"},{"id":19,"kind":2048,"name":"do","url":"classes/_task_.task.html#do","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"Task\".Task"},{"id":20,"kind":2048,"name":"elseDo","url":"classes/_task_.task.html#elsedo","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"Task\".Task"},{"id":21,"kind":4194304,"name":"Reject","url":"modules/_task_.html#reject","classes":"tsd-kind-type-alias tsd-parent-kind-external-module tsd-has-type-parameter","parent":"\"Task\""},{"id":22,"kind":65536,"name":"__type","url":"modules/_task_.html#reject.__type-2","classes":"tsd-kind-type-literal tsd-parent-kind-type-alias tsd-is-not-exported","parent":"\"Task\".Reject"},{"id":23,"kind":4194304,"name":"Resolve","url":"modules/_task_.html#resolve","classes":"tsd-kind-type-alias tsd-parent-kind-external-module tsd-has-type-parameter","parent":"\"Task\""},{"id":24,"kind":65536,"name":"__type","url":"modules/_task_.html#resolve.__type-3","classes":"tsd-kind-type-literal tsd-parent-kind-type-alias tsd-is-not-exported","parent":"\"Task\".Resolve"},{"id":25,"kind":4194304,"name":"Cancel","url":"modules/_task_.html#cancel","classes":"tsd-kind-type-alias tsd-parent-kind-external-module","parent":"\"Task\""},{"id":26,"kind":65536,"name":"__type","url":"modules/_task_.html#cancel.__type","classes":"tsd-kind-type-literal tsd-parent-kind-type-alias tsd-is-not-exported","parent":"\"Task\".Cancel"},{"id":27,"kind":4194304,"name":"Computation","url":"modules/_task_.html#computation","classes":"tsd-kind-type-alias tsd-parent-kind-external-module tsd-has-type-parameter","parent":"\"Task\""},{"id":28,"kind":65536,"name":"__type","url":"modules/_task_.html#computation.__type-1","classes":"tsd-kind-type-literal tsd-parent-kind-type-alias tsd-is-not-exported","parent":"\"Task\".Computation"},{"id":29,"kind":64,"name":"noop","url":"modules/_task_.html#noop","classes":"tsd-kind-function tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"Task\""},{"id":30,"kind":1,"name":"\"index\"","url":"modules/_index_.html","classes":"tsd-kind-external-module"}]}; \ No newline at end of file diff --git a/docs/classes/_task_.task.html b/docs/classes/_task_.task.html index f6227aa..eab94c8 100644 --- a/docs/classes/_task_.task.html +++ b/docs/classes/_task_.task.html @@ -930,6 +930,9 @@
Execute a Promise in the context of a successful task, as though it were - a Task. Flatten the result and convert to a Task.
-In theory, it means that you could take a browser api like fetch
, which
- is promises all the way down, and chain it right into a normal task chain.
For example:
-Task.succeed('https://jsonplaceholder.typicode.com/posts/1')
- .andThenP(fetch)
- .andThenP(result => result.json())
- .andThen(obj => someDecoder.decodeAny(obj).cata(Err: Task.fail, Ok: Task.succeed))
- .fork(
- err => `You died: ${err}`,
- someThing => doSomethingAwesomeHereWithThis(someThing)
- )
- Assign encapsulates a pattern of building up an object (or a scope) from
- a series of Task results. Without assign
, you would need to nest a series
- of andThen
calls to build a shared javascript scope if you needs to
- combine results. That pattern can become indistinguishable from callback
- hell. Using assign
, you can flatten out your call chain, while maintaining
- type safety.
The idea and the base implementation came from this blog post: - https://medium.com/@dhruvrajvanshi/simulating-haskells-do-notation-in-typescript-e48a9501751c
-Inject a side-effectual function into a task call chain. Task themselves are the - appropriate way to handle side-effects that you care about, but sometimes you - may want to do an fire-and-forget side effect. The most common example of this - is performing a logging the current value of a Task.
-Task.succeed('hi')
- .do(v => console.log(v))
- .andThen(doSomethingWithGreeting)
do
will only run in the context of a successful task.
Run the task. If the task fails, the reject function is called, and passed - the error. If the task succeeds, then the resolve function is called with - the task result.
-The fork function also returns a Cancel function. Calling the cancel
- function will abort the task, provided that the task actually supports
- cancelling. succeed
and fail
, for example, return the cancel function,
- but it is a No Op, since those tasks resolve immediately.
Execute a function in the context of a successful task
-Execute a function in the context of a failed task.
-Execute a Task in the context of a failed task. Flatten the result.
-Creates a new task that will run a series of tasks in parallel. If any - of the tasks reject, then all other results are discarded. If all tasks - resolve, then the an array of results is returned.
-This is comparable to Promise.all
-Implementation is based on https://github.com/futurize/parallel-future
-A Task that always fails. Rejects with err
.
Converts a function that returns a Promise into a Task.
-loop
returns a higher-order task forks the "inner" task until the inner task
- succeeds. Retries forking the task on the interval number the same as using
- setTimeout.
The cancel function returned when the loop is forked can be called to cancel the - loop. Cancelling the loop causes the task to never resolve.
-Creates a new Task from an Array of Tasks. When forked, all tasks are - forked in parallel. The first task to complete (either rejected or resolved) - is preserved. All other results are discarded.
-This could be used for a simple timeout mechanism. If the timeout rejects - before the fetch completes, you'll get a timeout error.
-new Task([longFetchTask, timeoutTask])
- A Task that is always successful. Resolves to t
.
Execute a Task in the context of a successful task. Flatten the result.
-