Skip to content
Snippets Groups Projects
Commit 90bcc2c8 authored by David Sehnal's avatar David Sehnal
Browse files

ValueCell updates

parent 93796e56
No related branches found
No related tags found
No related merge requests found
...@@ -5,11 +5,11 @@ ...@@ -5,11 +5,11 @@
*/ */
/** A mutable value reference. */ /** A mutable value reference. */
interface ValueRef<T> { value: T } interface ValueRef<T> { ref: T }
namespace ValueRef { namespace ValueRef {
export function create<T>(value: T): ValueRef<T> { return { value }; } export function create<T>(ref: T): ValueRef<T> { return { ref }; }
export function update<T>(cell: ValueRef<T>, value: T) { cell.value = value; return cell; } export function set<T>(ref: ValueRef<T>, value: T) { ref.ref = value; return ref; }
} }
let _valueBoxId = 0; let _valueBoxId = 0;
...@@ -50,10 +50,12 @@ namespace ValueCell { ...@@ -50,10 +50,12 @@ namespace ValueCell {
/** If diffInfo is not specified, copy the old value */ /** If diffInfo is not specified, copy the old value */
export function update<T, D>(cell: ValueCell<T, D>, value: T): ValueCell<T, D> { export function update<T, D>(cell: ValueCell<T, D>, value: T): ValueCell<T, D> {
ValueRef.update(cell, ValueBox.withValue(cell.value, value)); return ValueRef.set(cell, ValueBox.withValue(cell.ref, value));
return cell; }
export function set<T, D>(cell: ValueCell<T, D>, box: ValueBox<T, D>): ValueCell<T, D> {
return ValueRef.set(cell, box);
} }
} }
export { ValueRef, ValueBox, ValueCell }; export { ValueRef, ValueBox, ValueCell };
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment