All Projects â†’ staltz â†’ Callbag Basics

staltz / Callbag Basics

Licence: mit
👜 Tiny and fast reactive/iterable programming library

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Callbag Basics

callbag-subscribe
A callbag sink (listener) that connects an Observer a-la RxJS. 👜
Stars: ✭ 17 (-98.95%)
Mutual labels:  reactive, observables, callbag
Documentation
How does it all fit together?
Stars: ✭ 177 (-89.07%)
Mutual labels:  reactive, observables
callbag-rs
Rust implementation of the callbag spec for reactive/iterable programming
Stars: ✭ 25 (-98.46%)
Mutual labels:  reactive, callbag
servable
"simple" observable implementation based off RxJS & kefir Docs
Stars: ✭ 14 (-99.14%)
Mutual labels:  reactive, observables
Mobx React Form
Reactive MobX Form State Management
Stars: ✭ 1,031 (-36.32%)
Mutual labels:  reactive, observables
Toy Rx
A tiny implementation of RxJS that actually works, for learning
Stars: ✭ 290 (-82.09%)
Mutual labels:  reactive, observables
Awesome Rxjs
A collection of awesome RxJS resources
Stars: ✭ 314 (-80.61%)
Mutual labels:  reactive, observables
Platform
Reactive libraries for Angular
Stars: ✭ 7,020 (+333.6%)
Mutual labels:  reactive, observables
Inferno Most Fp Demo
A demo for the ReactJS Tampa Bay meetup showing how to build a React+Redux-like architecture from scratch using Inferno, Most.js, reactive programmning, and various functional programming tools & techniques
Stars: ✭ 45 (-97.22%)
Mutual labels:  reactive, observables
Karet
Karet is a library that allows you to embed Kefir observables into React VDOM
Stars: ✭ 81 (-95%)
Mutual labels:  reactive, observables
Spec
The AsyncAPI specification allows you to create machine-readable definitions of your asynchronous APIs.
Stars: ✭ 1,860 (+14.89%)
Mutual labels:  reactive
Rxphp
Reactive extensions for PHP
Stars: ✭ 1,580 (-2.41%)
Mutual labels:  observables
Vue Screen
Reactive screen size and media query states for VueJS
Stars: ✭ 120 (-92.59%)
Mutual labels:  reactive
Fable.reaction
Fable Reaction - Reactive (AsyncRx) for F# Elmish and Fable
Stars: ✭ 122 (-92.46%)
Mutual labels:  reactive
Swiftlysalesforce
The swiftest way to build iOS apps that connect to Salesforce
Stars: ✭ 115 (-92.9%)
Mutual labels:  reactive
Knotx
Knot.x is a highly-efficient and scalable integration framework designed to build backend APIs
Stars: ✭ 119 (-92.65%)
Mutual labels:  reactive
Rxasdatasources
RxDataSource for AsyncDisplayKit/Texture
Stars: ✭ 114 (-92.96%)
Mutual labels:  reactive
Bistate
A state management library for React combined immutable, mutable and reactive mode
Stars: ✭ 113 (-93.02%)
Mutual labels:  reactive
Revogrid
Powerful virtual data grid smartsheet with advanced customization. Best features from excel plus incredible performance 🔋
Stars: ✭ 1,870 (+15.5%)
Mutual labels:  reactive
Rapidoid
Rapidoid - Extremely Fast, Simple and Powerful Java Web Framework and HTTP Server!
Stars: ✭ 1,571 (-2.96%)
Mutual labels:  reactive

Callbag basics 👜

Basic callbag factories and operators to get started with. Callbag is just a spec, but callbag-basics is a real library you can use.

Highlights:

  • Supports reactive stream programming
  • Supports iterable programming (also!)
  • Same operator works for both of the above
  • Tiny! Weighs just 7kB
  • Fast! Faster than xstream and RxJS
  • Extensible: no core library! Everything is a utility function

Imagine a hybrid between an Observable and an (Async)Iterable, that's what callbags are all about. In addition, the internals are tiny because it's all done with a few simple callbacks, following the callbag spec. As a result, it's tiny and fast.

Usage

npm install callbag-basics

Import operators and factories:

const {forEach, fromIter, map, filter, pipe} = require('callbag-basics');

Try it online

Reactive programming examples

Log XY coordinates of click events on <button> elements:

const {forEach, fromEvent, map, filter, pipe} = require('callbag-basics');

pipe(
  fromEvent(document, 'click'),
  filter(ev => ev.target.tagName === 'BUTTON'),
  map(ev => ({x: ev.clientX, y: ev.clientY})),
  forEach(coords => console.log(coords))
);

// {x: 110, y: 581}
// {x: 295, y: 1128}
// ...

Pick the first 5 odd numbers from a clock that ticks every second, then start observing them:

const {forEach, interval, map, filter, take, pipe} = require('callbag-basics');

pipe(
  interval(1000),
  map(x => x + 1),
  filter(x => x % 2),
  take(5),
  forEach(x => console.log(x))
);

// 1
// 3
// 5
// 7
// 9

Iterable programming examples

From a range of numbers, pick 5 of them and divide them by 4, then start pulling those one by one:

const {forEach, fromIter, take, map, pipe} = require('callbag-basics');

function* range(from, to) {
  let i = from;
  while (i <= to) {
    yield i;
    i++;
  }
}

pipe(
  fromIter(range(40, 99)), // 40, 41, 42, 43, 44, 45, 46, ...
  take(5), // 40, 41, 42, 43, 44
  map(x => x / 4), // 10, 10.25, 10.5, 10.75, 11
  forEach(x => console.log(x))
);

// 10
// 10.25
// 10.5
// 10.75
// 11

API

The list below shows what's included.

Source factories

Sink factories

Transformation operators

Filtering operators

Combination operators

Utilities

More

Terminology

  • source: a callbag that delivers data
  • sink: a callbag that receives data
  • puller sink: a sink that actively requests data from the source
  • pullable source: a source that delivers data only on demand (on receiving a request)
  • listener sink: a sink that passively receives data from the source
  • listenable source: source which sends data to the sink without waiting for requests
  • operator: a callbag based on another callbag which applies some operation

Contributing

The Callbag philosophy is: build it yourself. :) You can send pull requests, but even better, don't depend on the repo owner accepting it. Just fork the project, customize it as you wish, and publish your fork on npm. As long as it follows the callbag spec, everything will be interoperable! :)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].