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