Skip to content

Minimal property tree instantiation with data binding and distributed change notifications. Intended to simplify the testing of the FluidFramework's large data use-cases.

License

Notifications You must be signed in to change notification settings

dstanesc/shared-property-map

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shared Property Map

Minimal property tree instantiation with data binding and distributed change notifications. Intended to simplify the testing of FluidFramework's larger data use-cases.

API

/*
 * Factory 
 */
export async function initMap(
    mapId: string | undefined,
    leafAdd: UpdateCallback,
    leafUpdate: UpdateCallback,
    leafRemove: DeleteCallback,
    treeClass: any = SharedPropertyTree,
    registerSchemaFlag: boolean = true
): Promise<SharedPropertyMap> 

/*
 * Map like interface
 */
export interface SharedPropertyMap {
    //basic functions
    delete(key: string): void;
    forEach(callbackfn: (value: string, key: string) => void): void;
    get(key: string): string | undefined;
    has(key: string): boolean;
    set(key: string, value: string): this;
    keys(): string[];
    // enhanced semantics, call fails if the key exists
    insert(key: string, value: string): this;
    // bulk variants for efficiency
    insertMany(map: Map<string, string>): this;
    updateMany(map: Map<string, string>): this;
    deleteMany(keys: string[]): void;
    // map identity token (needed for distributed editing)
    mapId(): string;
    // make changes visible to remote peers
    commit(): void;
    // container life-cycle
    dispose(): void;
}

Install

npm install --save-dev @dstanesc/shared-property-map

Usage

import { initMap } from '@dstanesc/shared-property-map';
const sharedMap = await initMap(
  mapId,
  updateLocalModel,
  updateLocalModel,
  deleteLocalModel
);
sharedMap.set("key1", "abc");
sharedMap.set("key2", "def");
sharedMap.commit();

Demo

Configure Fluid Service

Configure the Fluid service w/ environment variables FLUID_MODE=frs|router|tiny

If frs is opted for, set-up both SECRET_FLUID_TENANT and SECRET_FLUID_TOKEN env. vars. (as configured in your azure service - Tenant Id respectively Primary key )

Example

FLUID_MODE=frs
SECRET_FLUID_TOKEN=xyz
SECRET_FLUID_TENANT=xyz

Build & Test

Note: npm tests are pre-configured with the FLUID_MODE=tiny setting (see package.json)

npx tinylicious
npm run clean
npm install --legacy-peer-deps
npm run build
npm run test

Licenses

Licensed under either Apache 2.0 or MIT at your option.

About

Minimal property tree instantiation with data binding and distributed change notifications. Intended to simplify the testing of the FluidFramework's large data use-cases.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published