Giter Club home page Giter Club logo

core's Introduction

Motorcycle.js

An official subproject of Cycle.js built on top most.js instead of RxJS for its Observable/Stream implementation, and using Snabbdom to interact with the DOM.

Join the chat at https://gitter.im/cyclejs/core Build Status

Install

$ npm install @motorcycle/core // you can but don't ;)
$ npm install @cycle/most-run

Merging with Cycle.js

We are in the process of merging this project with Cycle.js. But Why?

We get to merge two wonderful communities together and focus on solving problems rather than duplicating efforts. Stream conversions are also now done in a mostly automatic way! Want to use a driver written in xstream or Rx 5? No problem if the driver is written for Cycle.js Diversity. It will be entirely seamless for you :)

Libraries that will continue to be maintained for most.js only

DOM Driver

@motorcycle/dom will continue to be the speed king that it currently is. It is at 100% feature parity with the latest Cycle.js Diversity version of @cycle/dom as of v2.0.0. However, it will not do any stream conversion like @cycle/dom to maximize performance to its greatest potential. @motorcycle/html has be rolled into this library for ease of maintanence going forward as well. Now imported as

import {makeHTMLDriver} from '@motorcycle/dom'
HTTP Driver

@motorcycle/http will soon be at feature parity with the newest version of @cycle/http and will be maintained to avoid the need to import xstream as a dependency.

What about everything else that used to be here?
  • @motorcycle/core - Please use @cycle/most-run
  • @motorcycle/history - Please use @cycle/history, it is 100% stream library agnostic and will not add any unneeded dependencies.
  • @motorcycle/router - Please use cyclic-router, it is also 100% stream agnostic and will not andd any unneeded dependencies.
  • @motorcycle/local-storage - This was a poorly done library to begin with, and I don't wish for anyone to reach for it. There is the very great @cycle/storage driver, which with v3 can do stream conversions when used with @cycle/most-run. However it is written in xstream, and will require the xstream library to also be imported. local-storage as driver is very easily implemented per individual needs, please stop by the Cycle.js gitter or open an issue to discuss here.

Want to Contribute?

If you found an issue or want to contribute code, please read the contributing guidelines.

If would like to have a repository considered for inclusion in the Motorcycle.js Github and NPM organizations, please open an issue first to avoid duplication of effort and further the possibility of your work being accepted. Afterwards, please refer to our repository guidelines.

Useful Utilities

  • most-subject - A subject implementation for most.js
  • most-proxy - Declarative circular dependencies for most.js

API

run(main, drivers)

Importing
// Why are you still using @motorcycle/core
import Motorcycle from '@motorcycle/core'

Motorcycle.run(main, drivers)

// What you should be doing
import Cycle from '@cycle/most-run'

Cycle.run(main, drivers)

Takes a main function and circularly connects it to the given collection of driver functions.

The main function takes an object of sources as input. Sources are the outputs from the various drivers. To complete the cycle, main should return a sinks object, which is a mapping of return values from the program to the drivers, i.e., inputs to the drivers, usually Observables/Streams.

Arguments:

main :: Function - a function that takes sources as input and outputs a collection of sinks Observables/Streams.

drivers :: Object - an object where keys are driver names and values are driver functions.

{onError} :: Object - an object which currently only accepts an onError() function. The optional onError() function allows for defining a custom Function to be called when an error occurs in a stream from your application.

Return:

(Object) an object containing sources, sinks, and dispose() that can be used for debugging or testing.

sources :: Object<most.Stream> - The collection that is passed to your main function. The output of the drivers passed to run()

sinks :: Object<most.Stream> - The collection that is returned from your main function. The input to the drivers.

dispose :: Function - A function that will dispose of streams from sinks and sources.

core's People

Contributors

axefrog avatar bouzuya avatar frikki avatar gitter-badger avatar tylors avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.