You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Flyd module for binding a stream of values to the URL querystring. You may do this with as many streams as you want simultaneously. Also, the values from the URL querystring will pushed to the streams on pageload, if present. This is useful for storing and tracking UI state in the URL to be restored on pageload (like for searching, filtering, or tracking what page they are on).
Signature
String -> Stream a -> Stream a
This module exports a single function that takes a String (a query parameter key name) and an existing stream and binds the values from that stream into the URL querystring under the given key.
Usage
conststream=require('flyd').streamconstqueryString=require('flyd-stream-querystring')location.search// -> ""constfinn=stream(),jake=stream()queryString('finn',finn)queryString('jake',jake)finn('human')location.search// -> "?finn=human"jake('dog')location.search// -> "?finn=human&jake=dog"finn('human-boy')location.search// -> "?finn=human-boy&jake=dog"// Pushing empty string or null to a querystring stream makes the value blankfinn(null)location.search// -> "?finn=&jake=dog"// Pushing undefined to a querystring stream removes it from the urlfinn(undefined)location.search// -> "?jake=dog"
About
Push every value from a flyd stream into the url query. And pull the url query value on pageload. Useful for persistent page state like searches.