Skip to content

Commit

Permalink
New values
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxwellBo committed Oct 6, 2024
1 parent 95f8d3c commit c95efa9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,9 @@ export class CelineModule {
*/
public mutable<T>(name: string, value: T): typeof Mutable<T> {
const m = Mutable(value);
// @ts-ignore - some really scary stuff going on here
this.cell(name, m);
// @ts-ignore - some really scary stuff going on here
return m;
}
}
Expand All @@ -248,7 +250,7 @@ export class CelineModule {
* @param value - The initial value
* @returns A mutable object with getter/setter for the value
*/
function Mutable<T>(value: T) {
function Mutable<T>(value: T): { value: T } {
let change: (value: T) => void;
return Object.defineProperty(
library.Generators.observe((_: (value: T) => void) => {
Expand All @@ -260,7 +262,7 @@ function Mutable<T>(value: T) {
get: () => value,
set: (x: T) => void change((value = x)),
}
);
) as { value: T };
}

/**
Expand Down

0 comments on commit c95efa9

Please sign in to comment.