1.0.0 • Published 6 years ago

subject-with-filter v1.0.0

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
6 years ago

create-subject-with-filter

mimicing rxjs Subject exposing filter only. Attempts to create a small webpacked file using rxjs/Subject is currently too hard to 'patch'

Install

yarn add create-subject-with-filter

Usage

const {
	next: newMessage,
	subscribe: handleMessage,
	filter: filterMessage
} = createSubject()

//do something
handleMessage(msg => bar(msg))

//Send message
newMessage({payload:'bar'})

//filter the subscription
const filtered = filterMessage(msg => payload==='foo')

//subscribe and get the subscription back
const subscription = filtered.subscribe(msg => foo(msg))

///unsubscribe
subscription.unsubscribe()