@@ -2,23 +2,29 @@ package coconut.diffing;
22
33import coconut .ui .Ref ;
44
5- @:using (coconut.diffing. Factory . FactoryTools )
6- interface Factory <Data , Native , Target : Native > {
7- final type : TypeId ;
8- function create (data : Data ): Target ;
9- function update (target : Target , next : Data , prev : Data ): Void ;
10- }
5+ abstract class Factory <Data , Native , Target : Native > {
6+ public final type = new TypeId ();
7+
8+ public abstract function create (data : Data ): Target ;
9+ public abstract function update (target : Target , next : Data , prev : Data ): Void ;
1110
12- class FactoryTools {
13- static public function vnode <Data , Native , Concrete : Native , RenderResult : VNode <Native >>(f : Factory <Data , Native , Concrete >, data : Data , ? key : Key , ? ref : Ref <Concrete >, ? children : Children <RenderResult >): VNode <Native >
14- return new VNative <Data , Native , Concrete >(f , data , key , ref , children );
11+ /**
12+ Only used in hydration (by coconut.vdom). The currently encountered native node is passed to `adopt`.
13+ Return `null` if the wrong type of node is encountered.
14+ **/
15+ public function adopt (target : Native ): Null <Target > return null ;
16+ /**
17+ The actual implementation of the hydration (only used by coconut.vdom)
18+ **/
19+ public function hydrate (target : Target , data : Data ): Void {}
20+
21+ public function vnode <RenderResult : VNode <Native >>(data : Data , ? key : Key , ? ref : Ref <Target >, ? children : Children <RenderResult >): VNode <Native >
22+ return new VNative <Data , Native , Target >(this , data , key , ref , children );
1523}
1624
1725private typedef Dict <T > = Null <haxe. DynamicAccess <Null <T >>>;
1826
19- class Properties <Value , Native : {}, Target : Native > implements Factory <Dict <Value >, Native , Target > {
20-
21- public final type = new TypeId ();
27+ class Properties <Value , Native : {}, Target : Native > extends Factory <Dict <Value >, Native , Target > {
2228
2329 final construct : ()-> Target ;
2430 final apply : (target : Target , name : String , nu : Null <Value >, old : Null <Value >)-> Void ;
0 commit comments