Search in sources :

Example 1 with MergeResults

use of io.deephaven.web.client.api.subscription.ViewportData.MergeResults in project deephaven-core by deephaven.

the class JsTable method handleDelta.

public void handleDelta(ClientTableState current, DeltaUpdates updates) {
    current.onRunning(s -> {
        if (current != state()) {
            return;
        }
        if (nonViewportSub != null) {
            nonViewportSub.handleDelta(updates);
            return;
        }
        final ViewportData vpd = currentViewportData;
        if (vpd == null) {
            // if the current viewport data is null, we're waiting on an initial snapshot to arrive for a different
            // part of the viewport
            JsLog.debug("Received delta while waiting for reinitialization");
            return;
        }
        MergeResults mergeResults = vpd.merge(updates);
        if (mergeResults.added.size() == 0 && mergeResults.modified.size() == 0 && mergeResults.removed.size() == 0) {
            return;
        }
        CustomEventInit event = CustomEventInit.create();
        event.setDetail(vpd);
        // user might call setViewport, and wind up nulling our currentViewportData
        fireEvent(EVENT_UPDATED, event);
        // here
        for (Integer index : mergeResults.added) {
            CustomEventInit addedEvent = CustomEventInit.create();
            addedEvent.setDetail(wrap(vpd.getRows().getAt(index), index));
            fireEvent(EVENT_ROWADDED, addedEvent);
        }
        for (Integer index : mergeResults.modified) {
            CustomEventInit addedEvent = CustomEventInit.create();
            addedEvent.setDetail(wrap(vpd.getRows().getAt(index), index));
            fireEvent(EVENT_ROWUPDATED, addedEvent);
        }
        for (Integer index : mergeResults.removed) {
            CustomEventInit addedEvent = CustomEventInit.create();
            addedEvent.setDetail(wrap(vpd.getRows().getAt(index), index));
            fireEvent(EVENT_ROWREMOVED, addedEvent);
        }
    }, JsRunnable.doNothing());
}
Also used : ViewportData(io.deephaven.web.client.api.subscription.ViewportData) CustomEventInit(elemental2.dom.CustomEventInit) MergeResults(io.deephaven.web.client.api.subscription.ViewportData.MergeResults)

Aggregations

CustomEventInit (elemental2.dom.CustomEventInit)1 ViewportData (io.deephaven.web.client.api.subscription.ViewportData)1 MergeResults (io.deephaven.web.client.api.subscription.ViewportData.MergeResults)1