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

Commit 23ca2e3

Browse files
MonoidMusicianpaf31
authored andcommitted
Expose create again (#26)
In the main module for dependency reasons
1 parent 9a6bcdb commit 23ca2e3

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

src/FRP/Event.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ exports.keepLatest = function (e) {
144144
};
145145
};
146146

147-
function subject() {
147+
exports.create = function () {
148148
var subs = [];
149149
return {
150150
event: function(sub) {
@@ -157,19 +157,24 @@ function subject() {
157157
};
158158
},
159159
push: function(a) {
160-
for (var i = 0; i < subs.length; i++) {
161-
subs[i](a);
162-
}
160+
return function() {
161+
for (var i = 0; i < subs.length; i++) {
162+
subs[i](a);
163+
}
164+
};
163165
}
164166
};
165167
};
166168

167169
exports.fix = function(f) {
168-
var s = subject();
170+
var s = exports.create();
169171
var io = f(s.event);
170172

171173
return function(sub) {
172-
var cancel1 = io.input(s.push);
174+
var sub1 = function(a) {
175+
s.push(a)();
176+
};
177+
var cancel1 = io.input(sub1);
173178
var cancel2 = io.output(sub);
174179

175180
return function() {

src/FRP/Event.purs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module FRP.Event
22
( Event
3+
, create
34
, subscribe
45
, module Class
56
) where
@@ -107,3 +108,11 @@ foreign import subscribe
107108
. Event a
108109
-> (a -> Eff (frp :: FRP | eff) r)
109110
-> Eff (frp :: FRP | eff) (Eff (frp :: FRP | eff) Unit)
111+
112+
-- | Create an event and a function which supplies a value to that event.
113+
foreign import create
114+
:: forall eff a
115+
. Eff (frp :: FRP | eff)
116+
{ event :: Event a
117+
, push :: a -> Eff (frp :: FRP | eff) Unit
118+
}

0 commit comments

Comments
 (0)