Socket
Book a DemoInstallSign in
Socket

callbag-from-function

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

callbag-from-function

Create a callbag source from a function

latest
Source
npmnpm
Version
2.1.0
Version published
Maintainers
1
Created
Source

callbag-from-function

Generate a Callbag from a function. Whenever the function is called, the source will emit what the function returned.

npm install callbag-from-function

usage

const {source, emitter} = fromFunction(someFunc);

Now, whenever you call emitter with some ...args, source will emit what someFunc returns when called with ...args.

The emitter will also return the emitted value.

If no function is passed in, an identity function will be used.

The source is "hot" (using callbag-share), meaning it can take many listeners.

example

Wrapping an action creator in an app with a state stream.

const forEach = require('callbag-for-each');
const fromFunction = require('callbag-from-function');

const newName = str => ({type: 'NEWNAME', value: str});

const {source: newName$, emitter: wrappedNewName} = fromFunction(newName);

const forEach(newName$)(a => console.log("New name:", a.value));

wrappedNewName("Batman"); // New name: Batman

Keywords

callbag

FAQs

Package last updated on 23 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.