Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Commit

Permalink
Expose create again (#26)
Browse files Browse the repository at this point in the history
In the main module for dependency reasons
  • Loading branch information
MonoidMusician authored and paf31 committed Nov 22, 2017
1 parent 9a6bcdb commit 23ca2e3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/FRP/Event.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ exports.keepLatest = function (e) {
};
};

function subject() {
exports.create = function () {
var subs = [];
return {
event: function(sub) {
Expand All @@ -157,19 +157,24 @@ function subject() {
};
},
push: function(a) {
for (var i = 0; i < subs.length; i++) {
subs[i](a);
}
return function() {
for (var i = 0; i < subs.length; i++) {
subs[i](a);
}
};
}
};
};

exports.fix = function(f) {
var s = subject();
var s = exports.create();
var io = f(s.event);

return function(sub) {
var cancel1 = io.input(s.push);
var sub1 = function(a) {
s.push(a)();
};
var cancel1 = io.input(sub1);
var cancel2 = io.output(sub);

return function() {
Expand Down
9 changes: 9 additions & 0 deletions src/FRP/Event.purs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module FRP.Event
( Event
, create
, subscribe
, module Class
) where
Expand Down Expand Up @@ -107,3 +108,11 @@ foreign import subscribe
. Event a
-> (a -> Eff (frp :: FRP | eff) r)
-> Eff (frp :: FRP | eff) (Eff (frp :: FRP | eff) Unit)

-- | Create an event and a function which supplies a value to that event.
foreign import create
:: forall eff a
. Eff (frp :: FRP | eff)
{ event :: Event a
, push :: a -> Eff (frp :: FRP | eff) Unit
}

0 comments on commit 23ca2e3

Please sign in to comment.