A small functional reactive programming library for JavaScript.
Questions tagged [bacon.js]
198 questions
1
vote
2 answers
Failed to convert socket.io event to Bacon EventStream
Below the event binding on socket.io worked correctly,
io = require('socket.io')()
io.on 'connection', (socket) ->
console.log socket.id
io.listen 3000
Then tried to convert socket.io event to Bacon EventStream,
Bacon =…

sof
- 9,113
- 16
- 57
- 83
1
vote
1 answer
How to fork/duplicate a stream
I have an outer stream. I want to use this stream in two different ways.
First way is to just listen on values.
Second way is to build a new stream with flatMapConcat.
But I can't do both at once. I think I have to fork or duplicate the stream.
I've…

user3995789
- 3,452
- 1
- 19
- 35
1
vote
1 answer
How to make use of scan() more clear
I want to make a simple web page using bacon.js. It should have a button which toggles a boolean state by mouse click.
After setting up the streams, the app should be initialized by sending an object to an init stream. Here i just send the desired…

hhelwich
- 200
- 6
1
vote
1 answer
Combining all values in a Bacon stream into a single array
I'm building an application using React and Bacon.js.
I have a list of students like so:
var students = [
{"name": "student1"}
...
];
I then construct an EventStream using a Bacon.bus.
var studentStream = new…

Azeirah
- 6,176
- 6
- 25
- 44
1
vote
2 answers
Extracting sub-streams, based on a termination attribute
I have a stream where the events look something like this:
{
endOfSequence : false,
sequenceId: 12345,
data: [.....]
}
I need to terminate the sequence when endOfSequence === true. I started with takeWhile:
seq = stream.takeWhile(…

Peter Hall
- 53,120
- 14
- 139
- 204
1
vote
1 answer
How to filter a stream using short syntax, when the values are primitives
When I have a stream of objects, e.g.
values = Bacon.fromArray([ {'status':"active"}, {'status':"inactive"} ]);
I can apply a short form filter, like this:
activeStates = values.filter( ".status", "active" );
But when the original stream…

Peter Hall
- 53,120
- 14
- 139
- 204
1
vote
1 answer
Nice way to add errors to Bacon EventStream?
I've tried to find a good solution for adding errors to an bacon.js EventStream - and propagating them. All this because I wan't to handle the errors later possibly at multiple clients. I've found a hack with flatMap but it's a ... hack:
var…

flash42
- 71
- 6
1
vote
1 answer
Bacon.when not matching streams as expected
In experimenting with Bacon.js, I've come across the following unexpected behavior:
var email = $("#email")
.asEventStream("keyup")
.map(function(event) {
…

pdoherty926
- 9,895
- 4
- 37
- 68
1
vote
1 answer
Cope with Bacon.js's side effects
I'm a newbie to the Bacon.js, usually write programs in Haskell.
By my experience with Haskell, I want to describe some situations in Bacon.js as purely-functional-like approach.
Here is an example situation.
triggerStream is a source…

user3749167
- 161
- 6
1
vote
2 answers
Bacon.js: redo ajax request on error
I have an array of urls I want to make get requests to. I create a stream from the urls array, and flatMap ajax requests, like so:
responses = Bacon.fromArray(url_arr)
.flatMap(function(url) {Bacon.fromPromise($.get(url))})
Now, in the responses…

tldr
- 11,924
- 15
- 75
- 120
1
vote
1 answer
Combining streams with baconjs
I have asynchronous events that I need combining. I am constructing an array of N streams; each stream has an onValue function to process the returned data.
I have tried combining all of those streams into one onValues on top of the onValue, but it…

David Laberge
- 15,435
- 14
- 53
- 83
1
vote
1 answer
bacon.js: error event propagation in event streams
I want to use bacon.js for the following scenario:
1. read files in a directory
2. each file consists of a url, make http request to the url
3. write each response into a corresponding file in another directory
From the docs, I understand that the…

tldr
- 11,924
- 15
- 75
- 120
1
vote
1 answer
Aligning time series in bacon.js
I would like to use Bacon to combine time series with irregular timestamps in a single EventStream. Each event would contain the last value of each time series at the given time.
Here is a an example
var ts1 = new Bacon.fromArray([
[1,2], …

LouisChiffre
- 691
- 7
- 15
1
vote
1 answer
Resetting a Bacon property on value changed to empty
TL;DR
How can I reset emailProfile/aliasProfile when email/alias is cleared after having a value?
Slightly longer version
I have a form that has inputs for email and alias. Neither is mandatory. But, if you fill in the alias field, it might require…

nikc.org
- 16,462
- 6
- 50
- 83
1
vote
2 answers
Temporarily accumulate objects depending on the state of a different stream
I've been trying to teach myself FRP (and bacon.js specifically) by diving in head first on a new project. I've gotten pretty far on my own but recently ran into a problem that I can't seem to fight my way through:
I have an interface with a set of…

disantlor
- 43
- 4