fix: add _streamDiff to push/pop/reverse built-ins
Array-mutating built-in functions now emit DS._streamDiff() for streaming sync. Previously only signal assignments emitted diffs.
This commit is contained in:
parent
a943d2e2e9
commit
8c9f5e8bfb
1 changed files with 3 additions and 3 deletions
|
|
@ -719,12 +719,12 @@ impl JsEmitter {
|
|||
"push" if args.len() == 2 => {
|
||||
// push mutates array, need to get signal root name
|
||||
let root = self.get_signal_root_name(&args[0]);
|
||||
format!("(() => {{ {}.push({}); {root}.value = [...{root}.value]; return {root}.value; }})()",
|
||||
format!("(() => {{ {}.push({}); {root}.value = [...{root}.value]; DS._streamDiff(\"{root}\", {root}.value); return {root}.value; }})()",
|
||||
args_js[0], args_js[1], )
|
||||
}
|
||||
"pop" if args.len() == 1 => {
|
||||
let root = self.get_signal_root_name(&args[0]);
|
||||
format!("(() => {{ const _v = {}.pop(); {root}.value = [...{root}.value]; return _v; }})()",
|
||||
format!("(() => {{ const _v = {}.pop(); {root}.value = [...{root}.value]; DS._streamDiff(\"{root}\", {root}.value); return _v; }})()",
|
||||
args_js[0])
|
||||
}
|
||||
"filter" if args.len() == 2 => format!("{}.filter({})", args_js[0], args_js[1]),
|
||||
|
|
@ -733,7 +733,7 @@ impl JsEmitter {
|
|||
"contains" if args.len() == 2 => format!("{}.includes({})", args_js[0], args_js[1]),
|
||||
"reverse" if args.len() == 1 => {
|
||||
let root = self.get_signal_root_name(&args[0]);
|
||||
format!("(() => {{ {}.reverse(); {root}.value = [...{root}.value]; return {root}.value; }})()",
|
||||
format!("(() => {{ {}.reverse(); {root}.value = [...{root}.value]; DS._streamDiff(\"{root}\", {root}.value); return {root}.value; }})()",
|
||||
args_js[0])
|
||||
}
|
||||
"slice" if args.len() >= 2 => format!("{}.slice({})", args_js[0], args_js[1..].join(", ")),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue