File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
typescript/packages/lookslike-high-level/src/recipes Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 11import { h } from "@commontools/common-html" ;
2- import { Spell , type OpaqueRef } from "@commontools/common-builder" ;
2+ import { Spell , type OpaqueRef , handler } from "@commontools/common-builder" ;
33
44type CounterState = {
55 title : string ;
66 count : number ;
77} ;
88
9+ const thisHandler = handler <
10+ { } ,
11+ { count : number }
12+ > ( function ( ) {
13+ this . count += 1 ;
14+ } ) ;
15+
16+ const withHandler = handler <
17+ { } ,
18+ { count : number }
19+ > ( function ( { } , state ) {
20+ state . count += 1 ;
21+ } ) ;
22+
923export class CounterSpell extends Spell < CounterState > {
1024 constructor ( ) {
1125 super ( ) ;
@@ -32,7 +46,9 @@ export class CounterSpell extends Spell<CounterState> {
3246 < div >
3347 < common-input value = { title } oncommon-input = { this . dispatch ( "title" ) } />
3448 < p > count: { count } </ p >
35- < common-button onclick = { this . dispatch ( "increment" ) } > Increment</ common-button >
49+ < common-button onclick = { this . dispatch ( "increment" ) } > dispatch</ common-button >
50+ < common-button onclick = { thisHandler . bind ( { count} ) } > this</ common-button >
51+ < common-button onclick = { withHandler . with ( { count} ) } > with</ common-button >
3652 </ div >
3753 ) ;
3854 }
You can’t perform that action at this time.
0 commit comments