question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cycle Diversity: generalize for any stream library

See original GitHub issue

@TylorS and I started discussing how to migrate to RxJS 5, and/or support most.js streams without the need for a fork (Motorcycle.js) which mostly has copy-pasted code from some Cycle.js libraries.

We arrived at a proposal: Build a “base” run() function which is generic and assumes no stream library. It uses “stream adapters” to agree on an interface for each stream library. We need to build an adapter for each stream library. We also need to build “rx run()”, “most run()” which basically utilizes the common “base run()” but specify which stream library adapter is used. Drivers are given the stream adapter object from run(), and can written using whatever stream library.

@cycle/rx-run

import baseRun from '@cycle/base'
import streamAdapter from '@cycle/rx-adapter'

const Cycle = {
  run: (main, drivers) => baseRun(main, drivers, {streamAdapter})
}

export default Cycle

@cycle/dom

function domDriver(sink$) {...}

domDriver.streamAdapter = rxAdapter // mostAdapter 

Tasks to do

  • Create @cycle/base repo (essentially this PR #198 there) https://github.com/cyclejs/base
  • Write test for @cycle/base ensuring one-liner drivers work properly with default adapter.
  • Build https://github.com/cyclejs/rx5-adapter with tests, using StreamAdapter interface from base
  • Build https://github.com/cyclejs/rx4-adapter with tests, using StreamAdapter interface from base
  • PR on Cycle Core to implement it as @cycle/base + @cycle/rx-adapter, with #200 in mind
  • Make canary version for core
  • Make @cycle/rx-run npm package alias for @cycle/core
  • Rewrite Cycle DOM Driver in TypeScript with transposition off by default
  • Update base to export CycleSetup interface
  • Fix Cycle DOM diversity to adapt the out-facing streams for the app’s stream library
  • Convert some cycle-examples to use the canary version of dom with RxJS 5
  • Cycle HTTP driver in TypeScript and using driverFn.streamAdapter = rxAdapter
  • Make canary versions for http, test it around
  • Update power-ui to Diversity
  • xstream-adapter
  • xstream-run
  • Fix Cycle DOM last bugs with DOMSource.events() and isolate
  • Soft release core, dom, *-run, http, jsonp RC versions
  • Build https://github.com/cyclejs/most-adapter in JS with tests, using StreamAdapter interface from base
  • create @cycle/most-run https://github.com/cyclejs/most-run with #200 in mind
  • Unnecessary: Update motorcycle drivers to use driverFn.streamAdapter = mostAdapter
  • Update examples and TodoMVC to Diversity & xstream
  • Make bmi-typescript example, and fix Cycle DOM TypeScript problems, issue #307
  • Write http-random-user in TypeScript to make sure HTTP Driver is also working well
  • Change HoldSubject to Subject in stream adapters. It’s not needed.
  • Rework makeHTMLDriver(callback)
  • mockDOMSource should return a stream of the app’s own stream library.
  • DOMSource.select().elements should return WhateverStream interface, not type any
  • foo-adapter and foo-run: remove dispose(), add remember()
  • Update cycle history to use stream adapter remember()
  • Update TodoMVC using cycle history
  • Fix Cycle DOM documentation generation
  • Update cycle.js.org
  • cycle.js.org documentation page
  • Write Release notes and migration guide
  • Merge branches diversity to master, and publish non-rc versions
    • Cycle Core / Rx Run
    • DOM
    • HTTP
    • JSONP
    • examples
    • cyclejs.github.io
    • others
  • npm deprecate @cycle/core, use rx-run
  • Cycle DOM rxjs-typings, rx-typings, most-typings
  • Cycle HTTP rxjs-typings, rx-typings, most-typings

Breaking changes so far

  • DOMSource.select().observable => DOMSource.select().elements()
  • new Cycle.run API for those cases where sources and sinks are wanted: #200
  • Snabbdom instead of virtual-dom
    • breaking changes with hyperscript way of using attrs
  • top-level <svg> element is created with hyperscript-helpers but children elements created with hyperscript
  • mockDOMSource(sa, config) now takes a Stream Adapter as the first argument
  • makeHTMLDriver() => makeHTMLDriver(effectFn, options)
  • No more onError callback as an option to makeDOMDriver()
  • No more sinks.dispose and sources.dispose
  • HTML Driver returns and HTMLSource mimicking DOMSource. HTMLSource.element$ is the stream of HTML strings
  • HTTP Source is not response$$ but contains it. It’s an object with select(category: string): Observable<Observable<Response>>, filter(predicate: (res$: ResponseStream) => boolean): HTTPSource and response$$ property.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:11
  • Comments:74 (61 by maintainers)

github_iconTop GitHub Comments

23reactions
staltzcommented, Jun 29, 2016
6reactions
staltzcommented, Mar 14, 2016

Yes @SteveALee our plan is to precisely give a reasonable default option to the developer, so she doesn’t need to pick/choose when starting a project. This is after all a framework, not a library. But we also want to give developers freedom of some choice, without being an obstacle in their way.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Computationally designed libraries of fluorescent proteins ...
The diversity of function for a library of fluorescent proteins may be associated with either its extremes of color or its dispersion of...
Read more >
Rivers and Streams: Life in Flowing Water - Nature
Stream and river organisms reflect their localized niche, and surrounding landscape both upstream and downstream. River organisms have evolved in diverse and ...
Read more >
A stream classification system to explore the physical habitat ...
We developed a stream classification system of six physical habitat layers (size, gradient, hydrology, temperature, valley confinement, and ...
Read more >
Delay Diversity - an overview | ScienceDirect Topics
Practically, on the antenna, the transmitter delays the stream transmitted ... With the generalized delay-diversity scheme, the delay on the second antenna ...
Read more >
Scaling‐up biodiversity‐ecosystem functioning research
The diversity and distributions of plant, animal and microbial life ... the effect of algal diversity on stream water quality strengthens ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found