callbag-flatten

WebJar for callbag-flatten

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

callbag-flatten
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

callbag-flatten
WebJar for callbag-flatten
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/staltz/callbag-flatten

Download callbag-flatten

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/callbag-flatten/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>callbag-flatten</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/callbag-flatten/
implementation 'org.webjars.npm:callbag-flatten:1.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/callbag-flatten/
implementation ("org.webjars.npm:callbag-flatten:1.0.0")
'org.webjars.npm:callbag-flatten:jar:1.0.0'
<dependency org="org.webjars.npm" name="callbag-flatten" rev="1.0.0">
  <artifact name="callbag-flatten" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='callbag-flatten', version='1.0.0')
)
libraryDependencies += "org.webjars.npm" % "callbag-flatten" % "1.0.0"
[org.webjars.npm/callbag-flatten "1.0.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

callbag-flatten

Callbag operator that flattens a higher-order callbag source. Like RxJS "switch" or xstream "flatten". Use it with map to get behavior equivalent to "switchMap". Works on either pullable or listenable sources.

npm install callbag-flatten

examples

listenables

On each mouse click, start a stopwatch ticking every second:

const fromEvent = require('callbag-from-event');
const interval = require('callbag-interval');
const flatten = require('callbag-flatten');
const observe = require('callbag-observe');
const pipe = require('callbag-pipe');
const map = require('callbag-map');

const source = pipe(
  fromEvent(document, 'click'),
  map(() => interval(1000)),
  flatten,
  observe(x => console.log(x))
);

pullables

Loop over two iterables (such as arrays) and combine their values together:

const fromIter = require('callbag-from-iter');
const iterate = require('callbag-iterate');
const flatten = require('callbag-flatten');
const pipe = require('callbag-pipe');
const map = require('callbag-map');

const source = pipe(
  fromIter('hi'),
  map(char => pipe(
    fromIter([10, 20, 30]),
    map(num => char + num)
  )),
  flatten,
  iterate(x => console.log(x))
);

// h10
// h20
// h30
// i10
// i20
// i30

Versions

Version
1.0.0