Proposal: Make sources and sinks observables

Open
#582 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
typescript
Domain
api

Research direction

Start at the framework's run function and the existing Sources and Sinks types referenced in the proposal. Review how drivers and components are currently connected, then assess the observable and async migration examples. Done should be a decided API direction with compatibility expectations and validation identified.

Written by the indexing model from the issue text.

Description

issue is feature suggestion

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.

Dominant language
TypeScript
Stars
10.2k
Forks
423
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from cyclejs/cyclejs

All issues in cyclejs/cyclejs

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.