0.40.2 • Published 3 years ago

@fluidframework/last-edited-experimental v0.40.2

Weekly downloads
537
License
MIT
Repository
github
Last release
3 years ago

@fluidframework/last-edited-experimental

LastEditedTracker tracks the last edit to a document, such as the client who last edited the document and the time it happened.

It is created by passing a SharedSummaryBlock:

constructor(private readonly sharedSummaryBlock: SharedSummaryBlock);

It uses the SharedSummaryBlock to store the last edit details.

API

It provides the following APIs to get and update the last edit details:

public getLastEditDetails(): ILastEditDetails | undefined;
public updateLastEditDetails(message: ISequencedDocumentMessage);

The update should always be called in response to a remote op because: 1. It updates its state from the remote op. 2. It uses a SharedSummaryBlock as storage which must be set in response to a remote op.

The details returned in getLastEditDetails contain the IUser object and the timestamp of the last edit.

Last Edited Tracker Data Store

LastEditedTrackerDataObject is a runtime data store built on top of the LastEditedTracker. It creates and manages the SharedSummaryBlock so that the developer doesn't have to know about it or manage it.

It implements IProvideFluidLastEditedTracker and returns an IFluidLastEditedTracker which is an instance of LastEditedTracker above.

Setup

This package also provides a setupLastEditedTrackerForContainer method that can be used to set up a data store that provides IFluidLastEditedTracker to track last edited in a Container:

  • This setup function should be called during container instantiation so that ops are not missed.
  • Registers an "op" listener on the runtime. On each message, it calls the shouldDiscardMessageFn to check if the message should be discarded. It also discards all scheduler message. If a message is not discarded, it passes the last edited information from the message to the last edited tracker in the data store.

Note:

  • By default, message that are not of "Attach" and "Operation" type are discarded as per the shouldDiscardMessageDefault function:
function shouldDiscardMessageDefault(message: ISequencedDocumentMessage) {
    if (message.type === MessageType.Attach || message.type === MessageType.Operation) {
        return false;
    }
    return true;
}.
  • To discard specific ops, provide the shouldDiscardMessageFn funtion that takes in the message and returns a boolean indicating if the message should be discarded.

Usage

For tracking the last edit on a Container:

In instantiateRuntime, create a data store that implements IFluidLastEditedTracker. Then call setupLastEditedTrackerForContainer with the id of the data store:

public async instantiateRuntime(context: IContainerContext): Promise<IRuntime> {
    const dataStoreId = "root";

    // Create the ContainerRuntime
    const runtime = await ContainerRuntime.load(...);

    if (!runtime.existing) {
        // On first boot create the root data store with id `dataStoreId`.
        await runtime.createDataStore(dataStoreId, "lastEditedTracker");
    }

    setupLastEditedTrackerForContainer(dataStoreId, runtime);

    return runtime;
}

This will make sure that the root data store loads before any other data store and it tracks every op in the Container.

The IFluidLastEditedTracker can be retrieved from the root data store:

const response = await containerRuntime.request({ url: "/" });
const root = response.value;
const lastEditedTracker = root.IFluidLastEditedTracker;
0.39.8

3 years ago

0.39.7

3 years ago

0.39.6

3 years ago

0.39.5

3 years ago

0.40.3

3 years ago

0.40.2

3 years ago

0.40.0

3 years ago

0.40.1

3 years ago

0.39.4

3 years ago

0.41.0-25957

3 years ago

0.40.0-25719

3 years ago

0.40.0-25851

3 years ago

0.38.2

3 years ago

0.38.1

3 years ago

0.38.4

3 years ago

0.38.3

3 years ago

0.39.0-23272

3 years ago

0.39.1

3 years ago

0.39.0

3 years ago

0.39.3

3 years ago

0.39.2

3 years ago

0.39.0-23254

3 years ago

0.38.0

3 years ago

0.38.0-22040

3 years ago

0.38.0-22000

3 years ago

0.38.0-21934

3 years ago

0.37.3-21287

3 years ago

0.37.4

3 years ago

0.37.3

3 years ago

0.37.2

3 years ago

0.37.1

3 years ago

0.37.0

3 years ago

0.37.0-20517

3 years ago

0.37.0-20427

3 years ago

0.36.2-20364

3 years ago

0.35.7-20343

3 years ago

0.36.1

3 years ago

0.35.5

3 years ago

0.35.6

3 years ago

0.36.0-18883

3 years ago

0.36.0

3 years ago

0.35.4

3 years ago

0.33.5

3 years ago

0.34.3

3 years ago

0.35.3

3 years ago

0.34.2

3 years ago

0.33.4

3 years ago

0.35.2

3 years ago

0.35.1

3 years ago

0.35.0

3 years ago

0.35.0-16887

3 years ago

0.35.0-16170

3 years ago

0.34.1

3 years ago

0.34.0

3 years ago

0.34.0-14942

3 years ago

0.32.5

3 years ago

0.32.4

3 years ago

0.33.3

3 years ago

0.33.2

3 years ago

0.33.1

3 years ago

0.33.0

3 years ago

0.33.0-13708

3 years ago

0.32.3

3 years ago

0.31.2

3 years ago

0.32.2

3 years ago

0.32.1

3 years ago

0.32.0

3 years ago

0.31.1

3 years ago

0.31.0

3 years ago

0.30.4

3 years ago

0.30.3

3 years ago

0.30.2

3 years ago

0.30.1

3 years ago

0.30.0

3 years ago

0.29.4

3 years ago

0.29.3

4 years ago

0.28.9

4 years ago

0.29.2

4 years ago

0.29.1

4 years ago

0.28.8

4 years ago

0.29.0

4 years ago

0.28.7

4 years ago

0.27.15

4 years ago

0.27.14

4 years ago

0.28.6

4 years ago

0.27.13

4 years ago

0.28.5

4 years ago

0.27.12

4 years ago

0.28.4

4 years ago

0.28.3

4 years ago

0.27.11

4 years ago

0.27.10

4 years ago

0.28.1

4 years ago

0.28.0

4 years ago

0.28.2

4 years ago

0.27.9

4 years ago

0.26.10

4 years ago

0.27.8

4 years ago

0.27.7

4 years ago

0.26.9

4 years ago

0.27.6

4 years ago

0.26.8

4 years ago

0.27.5

4 years ago

0.26.7

4 years ago

0.27.4

4 years ago

0.26.6

4 years ago

0.26.5

4 years ago

0.27.3

4 years ago

0.26.4

4 years ago

0.27.2

4 years ago

0.27.1

4 years ago

0.26.3

4 years ago

0.26.2

4 years ago

0.27.0

4 years ago

0.26.1

4 years ago

0.26.0

4 years ago

0.26.0-3177

4 years ago