Skip to content
This repository was archived by the owner on Feb 20, 2021. It is now read-only.

bortexz/flyd-withLatestFrom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flyd-withLatestFrom

Build Status

withLatestFrom implementation for flyd streams.

Creates a stream that emits when the source emits, with the latest values from other streams. Only emits if the other streams all have value.

The values are emitted in an array where first value is the source value, followed by the other streams values.

withLatestFrom([...streams], source) -> Stream -> [sourceVal, ...streamsVals]

Usage

  it('Should emit with the values from streams', function() {
    var withLatestFrom$ = withLatestFrom([stream1$, stream2$], source$)
    stream1$(1)
    stream2$(2)
    assert.deepEqual(withLatestFrom$(), undefined)
    source$(3)
    assert.deepEqual(withLatestFrom$(), [3, 1, 2])
  })

  it('Should not emit if all streams have not emitted', function () {
    var withLatestFrom$ = withLatestFrom([stream1$, stream2$], source$)
    stream1$(1)
    assert.deepEqual(withLatestFrom$(), undefined)
    source$(2)
    assert.deepEqual(withLatestFrom$(), undefined)
  })

About

withLatestFrom implementation for flyd streams

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published