UNPKG

2.27 kBMarkdownView Raw
1
2# Cycle Run API with RxJS v4
3
4- [`run`](#run)
5- [`Cycle`](#Cycle)
6
7### <a id="run"></a> `run(main, drivers)`
8
9Takes a `main` function and circularly connects it to the given collection
10of driver functions.
11
12**Example:**
13```js
14import {run} from '@cycle/rx-run';
15const dispose = Cycle.run(main, drivers);
16// ...
17dispose();
18```
19
20The `main` function expects a collection of "source" Observables (returned
21from drivers) as input, and should return a collection of "sink" Observables
22(to be given to drivers). A "collection of Observables" is a JavaScript
23object where keys match the driver names registered by the `drivers` object,
24and values are the Observables. Refer to the documentation of each driver to
25see more details on what types of sources it outputs and sinks it receives.
26
27#### Arguments:
28
29- `main: Function` a function that takes `sources` as input and outputs a collection of `sinks` Observables.
30- `drivers: Object` an object where keys are driver names and values are driver functions.
31
32#### Return:
33
34*(Function)* a dispose function, used to terminate the execution of the Cycle.js program, cleaning up resources used.
35
36- - -
37
38### <a id="Cycle"></a> `Cycle(main, drivers)`
39
40A function that prepares the Cycle application to be executed. Takes a `main`
41function and prepares to circularly connects it to the given collection of
42driver functions. As an output, `Cycle()` returns an object with three
43properties: `sources`, `sinks` and `run`. Only when `run()` is called will
44the application actually execute. Refer to the documentation of `run()` for
45more details.
46
47**Example:**
48```js
49import Cycle from '@cycle/rx-run';
50const {sources, sinks, run} = Cycle(main, drivers);
51// ...
52const dispose = run(); // Executes the application
53// ...
54dispose();
55```
56
57#### Arguments:
58
59- `main: Function` a function that takes `sources` as input and outputs a collection of `sinks` Observables.
60- `drivers: Object` an object where keys are driver names and values are driver functions.
61
62#### Return:
63
64*(Object)* an object with three properties: `sources`, `sinks` and `run`. `sources` is the collection of driver sources, `sinks` is the
65collection of driver sinks, these can be used for debugging or testing. `run`
66is the function that once called will execute the application.
67