File tree Expand file tree Collapse file tree 2 files changed +14
-14
lines changed Expand file tree Collapse file tree 2 files changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -2,23 +2,23 @@ package scala.js
2
2
3
3
import virtualization .lms .common .{Structs , Functions , Base }
4
4
5
- trait React { this : Base with Functions =>
5
+ trait React { this : Base with Functions with Structs =>
6
6
7
- type RepEvents [+ A ] = Rep [ (A => Unit ) => Unit ]
7
+ type Events [+ A ] = Record { val onValue : (A => Unit ) => Unit }
8
8
9
- def Events [A : Manifest ](es : Rep [(A => Unit )] => Rep [Unit ]): RepEvents [ A ] = es
9
+ def Events [A : Manifest ](es : Rep [(A => Unit )] => Rep [Unit ]): Rep [ Events [ A ]] = new Record { val onValue = fun(es) }
10
10
11
- implicit class EventsOps [A : Manifest ](es : RepEvents [ A ]) {
11
+ implicit class EventsOps [A : Manifest ](es : Rep [ Events [ A ] ]) {
12
12
13
- def foreach (f : Rep [A ] => Rep [Unit ]): Rep [Unit ] = es(f)
13
+ def foreach (f : Rep [A ] => Rep [Unit ]): Rep [Unit ] = es.onValue.apply (f)
14
14
15
- def map [B : Manifest ](f : Rep [A ] => Rep [B ]): RepEvents [ B ] = Events [B ] { g =>
16
- es((e : Rep [A ]) => g(f(e)))
15
+ def map [B : Manifest ](f : Rep [A ] => Rep [B ]): Rep [ Events [ B ] ] = Events [B ] { g =>
16
+ es.onValue.apply ((e : Rep [A ]) => g(f(e)))
17
17
}
18
18
19
- def merge [B >: A : Manifest ](bs : RepEvents [ B ] ): RepEvents [ B ] = Events [B ] { f =>
20
- es((a : Rep [A ]) => f(a))
21
- bs((b : Rep [B ]) => f(b))
19
+ def merge [B >: A : Manifest ](bs : Rep [ Events [ B ]] ): Rep [ Events [ B ] ] = Events [B ] { f =>
20
+ es.onValue.apply ((a : Rep [A ]) => f(a))
21
+ bs.onValue.apply ((b : Rep [B ]) => f(b))
22
22
}
23
23
}
24
24
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ class TestReact extends FileDiffSuite2("test-out/") with Suite {
9
9
10
10
trait Prog { this : Base with FutureOps with React with JSDom with NumericOps with Functions with JSDebug =>
11
11
12
- def domEvents [A : Manifest ](event : EventName [A ], e : Rep [EventTarget ] = window): RepEvents [ A ] = Events [A ] { f =>
12
+ def domEvents [A : Manifest ](event : EventName [A ], e : Rep [EventTarget ] = window): Rep [ Events [ A ] ] = Events [A ] { f =>
13
13
e.on(event) { e => f(e) }
14
14
}
15
15
@@ -35,10 +35,10 @@ class TestReact extends FileDiffSuite2("test-out/") with Suite {
35
35
}
36
36
}
37
37
38
- /* testWithOutFile("events-foreach") { out =>
39
- val prog = new Prog with EffectExp with FutureOpsExp with React with JSDomExp with NumericOpsExp with JSFunctionsExp with JSDebugExp
38
+ testWithOutFile(" events-foreach" ) { out =>
39
+ val prog = new Prog with EffectExp with FutureOpsExp with React with JSDomExp with NumericOpsExp with JSFunctionsExp with IfThenElseExp with StructExp with JSDebugExp
40
40
val codegen = new JSGenEffect with JSGenFutureOps with JSGenDom with JSGenNumericOps with JSGenFunctions with JSGenDebug { val IR : prog.type = prog }
41
41
codegen.emitSource0(prog.main _, " main" , out)
42
- }*/
42
+ }
43
43
}
44
44
}
You can’t perform that action at this time.
0 commit comments