Skip to content

krawaller/callbag-latest

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

callbag-latest

Callbag operator that turns a listenable source into a pullable source, that emits the latest data (if any) from the listenable upon request.

Often useful in conjunction with callbag-sample.

npm install callbag-latest

example

const fromEvent = require('callbag-from-event');
const sample = require('callbag-sample');
const pipe = require('callbag-pipe');
const map = require('callbag-map');
const latest = require('callbag-latest');

const typeStream = pipe(
  fromEvent(inputField, "input"),
  map(e => e.target.value)
);

const submitActionStream = pipe(
  fromEvent(submitBtn, "click"),
  sample(latest(typeStream)), // turn click events to current value of input field
  map(v => ({type: "SUBMIT", value: v}))
);

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published