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