Skip to content

Commit 0ad6928

Browse files
author
Ellyse
committed
added docs and call Cell.get() which seems to be what i was looking for
1 parent a291872 commit 0ad6928

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

typescript/packages/common-cli/charm_test.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1+
/**
2+
* @file This file is Ellyse's exploration into the interactions between
3+
* charms, cells, and documents, and how they relate to common memory.
4+
*
5+
* I'm starting from the bottom (common memory) up and purposely calling
6+
* APIs that would normally call into common memory.
7+
*
8+
*/
19
import { CharmManager, Charm } from "../common-charm/src/charm.ts";
210
import { Cell } from "../common-runner/src/cell.ts";
311
import { DocImpl, getDoc } from "../common-runner/src/doc.ts";
412
import { EntityId } from "../common-runner/src/cell-map.ts";
513
import { storage } from "../common-charm/src/storage.ts";
614
import { getSpace, Space } from "../common-runner/src/space.ts";
715

8-
const replica = "ellyse6";
16+
const replica = "ellyse7";
917
const TOOLSHED_API_URL = "https://toolshed.saga-castor.ts.net/";
1018

11-
// i'm running common memory locally, so connect to it directly
12-
const BASE_URL = "http://localhost:8000"
13-
1419
// simple log function
1520
const log: <T>(s: T, prefix?: string) => void = (s, prefix?) =>
1621
console.log("-------------\n" + (prefix ? prefix : "") + ":\n" + JSON.stringify(s, null, 2));
@@ -21,22 +26,23 @@ function createCell(space: Space): Cell<Charm> {
2126
UI: "someui",
2227
"somekey": "some value",
2328
};
29+
30+
// make this a DocImpl<Charm> because we need to return a Cell<Charm> since
31+
// that's what CharmManger.add() needs later on
2432
const myDoc: DocImpl<Charm> = getDoc<Charm>(myCharm, crypto.randomUUID(), space);
25-
log(myDoc, "mydoc, should have name and ui and `somekey`");
2633
return myDoc.asCell();
2734
}
2835

2936
async function main() {
30-
3137
// create a charm manager to start things off
3238
const charmManager = new CharmManager(replica);
3339
log(charmManager, "charmManager");
3440

3541
// let's try to create a cell
3642
const space: Space = getSpace(replica);
3743
const cell: Cell<Charm> = createCell(space);
38-
log(cell, "same mydoc but asCell()");
39-
44+
log(cell.get(), "cell value from Cell.get()");
45+
4046
// this feels like magic and wrong,
4147
// but we crash in the next CharmManager.add() if this isn't set
4248
storage.setRemoteStorage(

0 commit comments

Comments
 (0)