cyclejs icon indicating copy to clipboard operation
cyclejs copied to clipboard

Proposal: Make sources and sinks observables

Open aronallen opened this issue 8 years ago • 1 comments

Hi,

Working on @cylce/sandbox I ran into a problem, because of multi-threading the sinks from a web worker are returned asynchronously, thus I had to tell my Sandbox driver which expected sinks my component would have.

At CycleConf there was some discussion on MegaDrivers, but I think making Sinks and Sources an observable might be the right way to go.

It would allow a developer to patch a driver while the application is running, and could open up for better debugging tools.

The run function would look like this

run(main, xs.of({
  DOM: makeDOMDriver()
}))

And a component would look like this

function Component (sources$: Stream<Sources> ) { 
  return xs.of({
    DOM: xs.of(<div/>)
  });
}

This would also make it possible to reroute Components in the DevTool during run-time.

It could mitigate the pain of adding new drivers when a sub-component way down the tree has a certain driver dependency.

The migration for existing code would look as so

run(async(main), xs.of({
  DOM: makeDOMDriver()
}))

The async method would mount any synchronously bound component.

aronallen avatar Apr 24 '17 08:04 aronallen

I believe it is outof scope of cycle/run itself, but should be just wrapper lib for run.

wclr avatar Apr 27 '17 07:04 wclr