How to use the mobx-utils.chunkProcessor function in mobx-utils

To help you get started, we’ve selected a few mobx-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IBA-Group-IT / IoT-data-simulator / ui / public-src / src / app / shared / stores / session / SessionsStore.js View on Github external
constructor(appStore, subscriptionManager, queryManager) {
        this.appStore = appStore;
        this._itemsMap = observable.map({});
        this.subscriptionManager = subscriptionManager;
        this.queryManager = queryManager;

        this.subscriptionManager.subscribeToAllSessions(
            this.handleSubscription
        );

        let bufferSize = this.bufferSize;
        const stop = chunkProcessor(this.logsBuffer, chunk => {
            let itemsCount = this.logs.length + chunk.length;
            let offset = itemsCount > bufferSize ? itemsCount - bufferSize : 0;
            this.logs.replace(
                this.logs.slice(offset).concat(chunk)
            )
            this.logsBuffer.clear();
        }, 200, bufferSize)
    }