FAQ Database Discussion Community


Kefir.js - How to stream events from a callback function?

javascript,frp
The Mousetrap.js library lets you bind a callback function to keys like so: Mousetrap.bind('space', function, 'keydown'); What's the best way to attach a stream to this without using the Bus of Doom? Should I use emitter or pool? I'm trying to get arrow keys hooked up in this fiddle: jsfiddle.net/vzafq25w...

How do I get keepWhen behaviour in Elm 0.15?

functional-programming,frp,elm
The keepWhen function from earlier versions of Elm was removed. I have ported an Elm application from 0.14, but I'm stuck at trying to get one part of it to work, where it's using keepWhen. So basically I'm looking for a function like keepWhen : Signal Bool -> a ->...

recursive update a “Behaviour” in Sodium yields 'thread blocked …'

haskell,frp,sodiumfrp
i would update a Behaviour (Cell / Val) from it's current value. but the following code throws a thread blocked indefinitely in an MVar operation exception. i have expected it prints three times 'value of i: '. what did i missing? - thanks. {-# LANGUAGE RecursiveDo #-} module Main where...

Haskell Netwire: wires of wires

haskell,frp,netwire
I'm playing around with the netwire package trying to get a feel for FRP, and I have a quick question. Starting with the following simple wires, I'm able to emit an event every 5 seconds (approx) myWire :: (Monad m, HasTime t s) => Wire s () m a Float...

Chaining promises with RxJS

javascript,observable,frp,rxjs
I'm new to RxJS and FRP in general. I had the idea of converting an existing promise chain in my ExpressJS application to be an observable for practice. I am aware that this probably isn't the best example but maybe someone can help shed some light. What I'm trying to...

Dynamic Elements based on Behaviour in threepenny-gui

haskell,frp,threepenny-gui
To put it simple, I am looking for a way to display a Behaviour (UI Element). My actual use-case is displaying a table, which can be filtered. So I have a function tableElement :: String -> UI Element (the String parameter being the filter condition) and an input field filterElement...

How do I merge signals in Helm?

haskell,frp,elm
I am working on a project using Helm, which is based on the Elm language. I need to trigger an event based on which signal out of a pair of signals arrives first. In Elm, I would use the merge function, but I cannot find an equivalent in Helm. The...

Never running stream Bacon.js. Callback never calls

node.js,reactive-programming,frp,bacon.js
I am trying to use Bacon stream as never ending loop but it doesn't work. var Bacon = require('baconjs'); var INTERVAL = 300; var tickStream = Bacon.interval(INTERVAL); var isMaster = tickStream.flatMap(function() { console.log('I never see the message'); return Bacon.once('some value'); }); Why don't I see anything in console? How can...

how to solve type issues with Moment t in reactive-banana?

haskell,reactive-programming,frp,reactive-banana
I'm trying to write a function like so: module Main where import Reactive.Banana import Reactive.Banana.Frameworks main = putStrLn "hello world" type MIDIMessage = (Int, Int, Double) startRBMidi f = do (addHandler, fire) <- newAddHandler :: IO (AddHandler MIDIMessage, Handler MIDIMessage) let networkDesc = do emidi <- fromAddHandler (addHandler :: AddHandler...

Task mixed in a signal

signals,frp,elm
I would like to send a message to mailbox inline with a signal. module Main where import Graphics.Element exposing (show) import Html exposing (..) import Html.Attributes exposing (..) import Html.Extra exposing (..) import Signal import Model.PickList exposing (pickList) import Model.BabyName.Debug as Debug headerPane : Html headerPane = header [ id...

How would I cancel a click event if it was following a drag event using Bacon.js?

javascript,reactive-programming,frp,bacon.js
So I have some event streams: let mouseUps = $(window) .asEventStream('mouseup'); let mouseDowns = $(window) .asEventStream('mousedown'); let mouseMoves = $(window) .asEventStream('mousemoves'); let drags = mouseDowns .flatMapLatest(() => mouseMoves.takeUntil(mouseUps)); let clicks = $(window) .asEventStream('click') .onValue(() => doThing()); I'd like to ignore clicks that get triggered right after a drag ends. I...