Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • Nov 01 20:43
    dependabot[bot] labeled #224
  • Nov 01 20:43
    dependabot[bot] opened #224
  • Nov 01 20:43

    dependabot[bot] on npm_and_yarn

    Bump minimatch, browserify, ist… (compare)

  • Jan 05 11:17
    JamesRamm opened #223
  • Dec 22 2021 01:00
    NeoVance opened #222
  • Sep 03 2021 02:29
    andersonleite closed #143
  • Aug 10 2021 17:36
    dependabot[bot] labeled #221
  • Aug 10 2021 17:36
    dependabot[bot] opened #221
  • Aug 10 2021 17:36

    dependabot[bot] on npm_and_yarn

    Bump path-parse from 1.0.5 to 1… (compare)

  • Jun 23 2021 12:24
    jakubmazanec closed #195
  • May 09 2021 06:46
    coveralls commented #220
  • May 09 2021 06:44
    dependabot[bot] labeled #220
  • May 09 2021 06:44
    dependabot[bot] opened #220
  • May 09 2021 06:44

    dependabot[bot] on npm_and_yarn

    Bump hosted-git-info from 2.5.0… (compare)

  • May 06 2021 22:03
    coveralls commented #219
  • May 06 2021 21:45

    dependabot[bot] on npm_and_yarn


  • May 06 2021 21:45
    dependabot[bot] closed #210
  • May 06 2021 21:45
    dependabot[bot] commented #210
  • May 06 2021 21:45
    dependabot[bot] labeled #219
  • May 06 2021 21:45
    dependabot[bot] opened #219
Einar Norðfjörð
It has to do with the guarantees flyd gives you. Atomic updates are guaranteed, but the execution order of streams is not.
const log = a => b => (console.log(a), b);

const stream$ = stream(true);
stream$.map(()=> {
  // flyd makes no guarantee that this chain will resolve instantly
  // we only guarantee atomic updates
  const s2 = stream$.map(log('1')).map(log('2'));
// It's only here that you can be sure that the map chain has run.
Antti Niemenpää
Daniel Gray
is there a better way to someArray.forEach(x => myStream(x)) ? in rxjs i can flatMap arrays into the stream, but chain always expects a stream and i don't see anything that looks similar
Einar Norðfjörð
you mean like a utility for
const fromArray = (list) => {
  const s = stream();
  // make sure the caller can process all values by
  // by putting the loop on the next tick
  setTimeout(()=> list.forEach(s));
  return s;
Daniel Gray
yeah, i guess? hm. how would i use that?
Einar Norðfjörð

let's say you have a stream of type Stream<T[]> and you want to turn it into a Stream<T>

Then you could:

const myStream = stream([1,2,3]);
// logs
// 1
// 2
// 3
here's a flems with an example
Daniel Gray
oh just .chain it, damn ok
thanks a lot!
Einar Norðfjörð
My pleasure. Hope it helps
Dannel Albert
Hey all. I’m new to flyd and relatively new to reactive streams. I’m trying to make sense of the difference between map and pipe. It’s a little confusing. I’m very familiar with map in the functional sense but I don’t know when I would need or want to use pipe
also, what notation is being used for the function signatures in the api docs? i’m assuming its some sort of functional notation but it’s a little confusing and I think I missed the part in the docs that spells it out
Einar Norðfjörð

Say you have a function that takes a type a and returns a type b. And say you have a stream that contains type a.

Then you can supply that function to the map method of the stream and receive a stream containing type b.

Pipe is a bit different.

Say you have a function that takes a stream of type a and returns a stream of type b. And a stream of type a.

Then you can supply that function to the streams pipe method to receive a stream of type b.

The type notation in the docs is Hindley milner.

Pipe is implemented as:

s.pipe = f => f(s)

And can be useful for things like flyd.scan.

Where the function is not a method on the stream

s.pipe(flyd.scan(reducer, initialValue))
Neville Franks

I'm using .map and need to execute an async function inside it to completion before it is called again. I've read the doc's and tried various things to no avail so far. For eaxmple this doesn't work:

const update = flyd.stream()

update.map( async patch => {
    await someAsyncFunction()   // don't call this again until it's promise resolves.
}).pipe( flyd.flattenPromise )

Hopefully someone more knowledgeable than me has a simple answer.

Antti Niemenpää
Hey, I'd like to ask if flyd.chainshould work like this? or if this is a bug? because it seems like a bug:
const stream$ = flyd.stream(false);

flyd.chain(() => {
  console.log('this is called 3 times?');
  return flyd.stream('foobar');
}, filter(val => val, stream$));

Hi #flyd!! I just wanted to share this- the Apollo GraphQL people have a new "reactive variable" concept in their 3.0. You... you may recognize it!! apollographql/apollo-client#5799 (It's the flyd pattern!!)
Mike Panciera
any ideas about the differences between this library and hareactive?
I would like to contribute to hareactive a bit but I am not sure if flyd is the 'new and improved' or a separate and parallel project. https://github.com/funkia/hareactive
Mike Panciera
I'm also wondering if there are any performance outliers in either library which might keep them from seeing use in real-time applications (games or real-time graphics)
Einar Norðfjörð
Hi there! As I understood paldepind, his more recent view on frp is encapsulated in hareactive, so I think hareactive is the new and improved flyd rather than the other way around
There’s a blog post here where you can read more about the thought process behind hareactive http://vindum.io/blog/behaviors-and-streams-why-both/
Mike Panciera
@nordfjord thanks
Patrik Johnson
Just as a PoV, you might not necessarily need continuous state as described in the above blog post, depending on app features/complexity. It might be relevant to handle in different ways in any case, so reviewing options before commiting might be a decent idea
James Ramm
Hej flyd! I'm pretty new to frp and one particular issue I'm having trouble with and struggling to find examples is polling an endpoint with streams (using flyd of course). I.e short polling. Is this a good use case of streams and can anyone point me towards some examples?
Ivan Pukhtin
@JamesRamm since flyd is push, I think that case require manual calling on endpoint and pushing onto the stream.