1 | import { CycleProgram, DisposeFunction, Drivers, MatchingDrivers, MatchingMain, Engine } from './types';
|
2 | export { FantasyObserver, FantasySubscription, FantasyObservable, DevToolEnabledSource, Sources, Sinks, SinkProxies, Driver, Drivers, DisposeFunction, MatchingDrivers, MatchingMain, Main, CycleProgram, Engine, WidenStream, GetValidInputs, } from './types';
|
3 | /**
|
4 | * A function that prepares the Cycle application to be executed. Takes a `main`
|
5 | * function and prepares to circularly connects it to the given collection of
|
6 | * driver functions. As an output, `setup()` returns an object with three
|
7 | * properties: `sources`, `sinks` and `run`. Only when `run()` is called will
|
8 | * the application actually execute. Refer to the documentation of `run()` for
|
9 | * more details.
|
10 | *
|
11 | * **Example:**
|
12 | * ```js
|
13 | * import {setup} from '@cycle/run';
|
14 | * const {sources, sinks, run} = setup(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 and outputs
|
22 | * `sinks`.
|
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 setup
|
30 | */
|
31 | export declare function setup<D extends MatchingDrivers<D, M>, M extends MatchingMain<D, M>>(main: M, drivers: D): CycleProgram<D, M>;
|
32 | /**
|
33 | * A partially-applied variant of setup() which accepts only the drivers, and
|
34 | * allows many `main` functions to execute and reuse this same set of drivers.
|
35 | *
|
36 | * Takes an object with driver functions as input, and outputs an object which
|
37 | * contains the generated sources (from those drivers) and a `run` function
|
38 | * (which in turn expects sinks as argument). This `run` function can be called
|
39 | * multiple times with different arguments, and it will reuse the drivers that
|
40 | * were passed to `setupReusable`.
|
41 | *
|
42 | * **Example:**
|
43 | * ```js
|
44 | * import {setupReusable} from '@cycle/run';
|
45 | * const {sources, run, dispose} = setupReusable(drivers);
|
46 | * // ...
|
47 | * const sinks = main(sources);
|
48 | * const disposeRun = run(sinks);
|
49 | * // ...
|
50 | * disposeRun();
|
51 | * // ...
|
52 | * dispose(); // ends the reusability of drivers
|
53 | * ```
|
54 | *
|
55 | * @param {Object} drivers an object where keys are driver names and values
|
56 | * are driver functions.
|
57 | * @return {Object} an object with three properties: `sources`, `run` and
|
58 | * `dispose`. `sources` is the collection of driver sources, `run` is the
|
59 | * function that once called with 'sinks' as argument, will execute the
|
60 | * application, tying together sources with sinks. `dispose` terminates the
|
61 | * reusable resources used by the drivers. Note also that `run` returns a
|
62 | * dispose function which terminates resources that are specific (not reusable)
|
63 | * to that run.
|
64 | * @function setupReusable
|
65 | */
|
66 | export declare function setupReusable<D extends Drivers>(drivers: D): Engine<D>;
|
67 | /**
|
68 | * Takes a `main` function and circularly connects it to the given collection
|
69 | * of driver functions.
|
70 | *
|
71 | * **Example:**
|
72 | * ```js
|
73 | * import run from '@cycle/run';
|
74 | * const dispose = run(main, drivers);
|
75 | * // ...
|
76 | * dispose();
|
77 | * ```
|
78 | *
|
79 | * The `main` function expects a collection of "source" streams (returned from
|
80 | * drivers) as input, and should return a collection of "sink" streams (to be
|
81 | * given to drivers). A "collection of streams" is a JavaScript object where
|
82 | * keys match the driver names registered by the `drivers` object, and values
|
83 | * are the streams. Refer to the documentation of each driver to see more
|
84 | * details on what types of sources it outputs and sinks it receives.
|
85 | *
|
86 | * @param {Function} main a function that takes `sources` as input and outputs
|
87 | * `sinks`.
|
88 | * @param {Object} drivers an object where keys are driver names and values
|
89 | * are driver functions.
|
90 | * @return {Function} a dispose function, used to terminate the execution of the
|
91 | * Cycle.js program, cleaning up resources used.
|
92 | * @function run
|
93 | */
|
94 | export declare function run<D extends MatchingDrivers<D, M>, M extends MatchingMain<D, M>>(main: M, drivers: D): DisposeFunction;
|
95 | export default run;
|