Skip to content

Commit

Permalink
$mol_view_tree2 mixed args in right bind
Browse files Browse the repository at this point in the history
  • Loading branch information
zerkalica committed Dec 16, 2023
1 parent 7296341 commit b4d1b44
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion switch/switch.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace $.$$ {
*/
export class $mol_switch extends $.$mol_switch {

value( next? : any ) {
value( next? : string ) {
return $mol_state_session.value( `${ this }.value()` , next ) ?? ''
}

Expand Down
4 changes: 2 additions & 2 deletions view/tree2/to/js/js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace $ {
] )
}
const op = prop.kids[0]
const is_delegate = op?.type === '<=' || op?.type === '<=>'
const is_delegate = op?.type === '<=' || op?.type === '<=>' || op?.type === '='
if( ! is_delegate && next ) addons.push( decorate() )

const val = prop.hack<Context>({
Expand Down Expand Up @@ -148,7 +148,7 @@ namespace $ {
]

if( $mol_view_tree2_class_match( input ) ) {
if( !next ) addons.push( decorate() )
if( ! next ) addons.push( decorate() )

const overrides = [] as $mol_tree2[]

Expand Down
3 changes: 3 additions & 0 deletions view/tree2/to/js/test/ex/right_hierarchy.view.tree
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
$mol_view_tree2_to_js_test_ex_right_hierarchy_foo $mol_object
Indexed* $mol_view_tree2_to_js_test_ex_right_hierarchy_bar
title? => indexed_title*?
id <= indexed_id* 0
prj $mol_view_tree2_to_js_test_ex_right_hierarchy_bar
domain* => prj_domain*
user => prj_user*
Expand Down
13 changes: 9 additions & 4 deletions view/tree2/to/js/test/ex/right_hierarchy_bar.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
namespace $ {
export class $mol_view_tree2_to_js_test_ex_right_hierarchy_bar extends $mol_object {
title() {
return 123
@ $mol_mem
title(next?: number) {
return 123 + (next ?? 0)
}
id() {
return 0
}

domain(id: string) {
@ $mol_mem_key
domain(id: number) {
return {
user() {
return {
id() {
return 1
return 1 + id
}
}
}
Expand Down
17 changes: 16 additions & 1 deletion view/tree2/to/js/test/js.right.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,26 @@ namespace $ {
'Right hierarchy'( $ ) {
const _foo = $mol_view_tree2_to_js_test_ex_right_hierarchy_foo
const foo = _foo.make({ $: _foo.$ })
type prj_user_id_assert = $mol_type_assert<ReturnType<typeof foo['prj_user_id']>, number >
type prj_domain_assert = $mol_type_assert<ReturnType<typeof foo['prj_domain']>, {
user: () => { id: () => number }
} >

$mol_assert_like(
foo.prj_user_id(1),
1
2
)
},

'Right mixed args'( $ ) {
const _foo = $mol_view_tree2_to_js_test_ex_right_hierarchy_foo
const foo = _foo.make({ $: _foo.$ })
foo.indexed_id = id => id + 25

$mol_assert_like( foo.indexed_title(1), 123 )
$mol_assert_like( foo.Indexed(0).id(), 25 )
$mol_assert_like( foo.Indexed(1).id(), 26 )
$mol_assert_like( foo.indexed_title(0, 2), 125 )
}

})
Expand Down

0 comments on commit b4d1b44

Please sign in to comment.