ctx-core 4.6.2 → 4.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Be, be__val__new_T, be_config_T, Ctx } from '../be_/index.js'
|
|
2
|
-
import type { memo_T } from '../rmemo/index.js'
|
|
2
|
+
import type { memo_T, sig_T } from '../rmemo/index.js'
|
|
3
3
|
export declare function be_memo_pair_<
|
|
4
4
|
val_T,
|
|
5
5
|
_memo_T extends memo_T<val_T> = memo_T<val_T>,
|
|
@@ -12,8 +12,8 @@ export declare function be_memo_pair_<
|
|
|
12
12
|
>(
|
|
13
13
|
rmemo__new:be__val__new_T<val_T>,
|
|
14
14
|
...subscriber_a_THEN_config:
|
|
15
|
-
|[...((ctx:Ctx,
|
|
16
|
-
|[...((ctx:Ctx,
|
|
15
|
+
|[...((ctx:Ctx, memosig:sig_T<val_T>)=>unknown)[]]
|
|
16
|
+
|[...((ctx:Ctx, memosig:sig_T<val_T>)=>unknown)[], config:be_config_T]
|
|
17
17
|
):be_memo_pair_T<val_T, _memo_T, ctx_T>
|
|
18
18
|
export type be_memo_pair_T<
|
|
19
19
|
val_T,
|
|
@@ -64,6 +64,26 @@ test('be_memo_pair_|+id|+is_source_|+oninit|+subscriber_a', ()=>{
|
|
|
64
64
|
equal(subscriber_count, 2)
|
|
65
65
|
equal(subscriber_dep_(ctx), 5)
|
|
66
66
|
})
|
|
67
|
+
test('be_memo_pair_|subscriber|receives a memosig to set the value of the memo', ()=>{
|
|
68
|
+
const ctx = ctx__new()
|
|
69
|
+
const [
|
|
70
|
+
,
|
|
71
|
+
base_,
|
|
72
|
+
base__set,
|
|
73
|
+
] = be_sig_triple_(()=>1)
|
|
74
|
+
const [
|
|
75
|
+
foobar$_,
|
|
76
|
+
foobar_,
|
|
77
|
+
] = be_memo_pair_(ctx=>1,
|
|
78
|
+
(ctx, foobar$)=>{
|
|
79
|
+
foobar$._ = base_(ctx) + 1
|
|
80
|
+
})
|
|
81
|
+
equal(foobar$_(ctx)._, 2)
|
|
82
|
+
equal(foobar_(ctx), 2)
|
|
83
|
+
base__set(ctx, 2)
|
|
84
|
+
equal(foobar$_(ctx)._, 3)
|
|
85
|
+
equal(foobar_(ctx), 3)
|
|
86
|
+
})
|
|
67
87
|
test('be_memo_pair_|be', ()=>{
|
|
68
88
|
const ctx = ctx__new()
|
|
69
89
|
let subscriber_count = 0
|