Simple alpha shared tree instantiation for testing
npm install @dstanesc/shared-tree-mapMinimal Fluid SharedTree DDS instantiation for testing purposes. Includes data binding.
```
npm install @dstanesc/shared-tree-map
Author data
`ts`
import { initMap } from "@dstanesc/shared-tree-map";
const sharedMap = await initMap(mapId, "tiny");
sharedMap.set("key1", "abc");
sharedMap.set("key2", "def");
sharedMap.delete("key1");
Subscribe to changes using the invalidation binder
`ts`
import { initMap } from "@dstanesc/shared-tree-map";
const sharedMap = await initMap(mapId, "tiny");
const binder = sharedMap.getInvalidationBinder();
binder.bindOnInvalid(() => {
updateLocalModel(sharedMap.asMap());
});
Subscribe to changes using the direct binder. It is unsafe to read the shared map directly from the callback. It is recommended to use the buffering binder instead.
`ts`
const binder = sharedMap.getDirectBinder();
binder.bindOnChange(
(key: string, value: string) => {
localModel.set(key, value);
},
(key: string) => {
localModel.delete(key);
}
);
Subscribe to changes using the buffering binder
`ts`
const binder = sharedMap.getBufferingBinder();
binder.bindOnChange(
(key: string, value: string) => {
localModel.set(key, value);
},
(key: string) => {
localModel.delete(key);
}
);
Subscribe to changes using the batching binder
`ts`
const binder = sharedMap.getBatchingBinder();
binder.bindOnBatch((batch: MapOperation[]) => {
for (const op of batch) {
if (op.type === "insert") {
localModel.set(op.key, op.value);
} else if (op.type === "delete") {
localModel.delete(op.key);
}
}
});
If using frs fluidMode, set-up both SECRET_FLUID_TENANT and SECRET_FLUID_TOKEN env. vars. (as configured in your azure service - Tenant Id respectively Primary key )
Example
``
SECRET_FLUID_TOKEN=xyz
SECRET_FLUID_TENANT=xyz
> Note: npm tests are pre-configured with the fluidMode=tiny setting (see package.json)
`sh`
npx tinylicious
`sh``
npm run clean
npm install
npm run build
npm run test
Licensed under either Apache 2.0 or MIT at your option.