Skip to content

Commit

Permalink
proxy: values
Browse files Browse the repository at this point in the history
  • Loading branch information
hbbio committed Nov 4, 2024
1 parent ab05fbb commit fdab57c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ abstract class SubscribeBench<V> {
// console.log(`Cell ${this.name}: `, `subscriber ${id} registered`);
const subscriber: [(value: V) => void, number] = [run, id];
this._subscribers.push(subscriber);
// returns an unsubscribe function
return () => {
// console.log({
// cell: this.name,
// subscriber: id,
// unsubscribeOccurrences: this._subscribers.map((f) => f[0] === run),
// });
// returns an unsubscribe function
const index = this._subscribers.indexOf(subscriber);
if (index !== -1) this._subscribers.splice(index, 1);
};
Expand Down
11 changes: 11 additions & 0 deletions src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,4 +280,15 @@ export class SheetProxy {
this._sheet.collect(...this._list);
this._list = [];
}

/**
* @todo transaction semantics
*/
async values<In extends AnyCell<unknown>[]>(
...l: In
): Promise<{ [K in keyof In]: In[K] extends AnyCell<infer T> ? T : never }> {
return Promise.all(l.map((cell) => cell.consolidatedValue)) as Promise<{
[K in keyof In]: In[K] extends AnyCell<infer T> ? T : never;
}>;
}
}

0 comments on commit fdab57c

Please sign in to comment.