mobx-shared-entities

3.0.4 • Public • Published

mobx-shared-entities

Model which helps to use pagination with tables

usage

import { Paginator } from 'mobx-shared-entities/paginator';

class SomeModel {
  paginator = new Paginator({
    disposer: this.disposer,
  });
}

someModel.paginator.toNextPage()
someModel.paginator.toPreviousPage()

someModel.paginator.inputData;

Model which helps to create ws connection with sending\receiving data from ws

usage

import { Socket } from 'mobx-shared-entities/socket';

class SomeModel {
  socket = new Socket({
    url: 'ws//localhost:8081',
    reconnect: { enabled: true },
  });
}

someModel.socket.open();

reaction(
  () => someModel.socker.message,
  (message) => {
    console.info('message', message);
  },
);

Model which helps to create step mechanism

usage

import { Stepper } from 'mobx-shared-entities/stepper';

class SomeModel {
  stepper = new Stepper({
    steps: [1, 2, 3],
  });
}

someModel.stepper.nextStep()
someModel.stepper.isLastStep;

someModel.stepper.activeStep;

Model with counter and start timer

usage

import { Ticker } from 'mobx-shared-entities/ticker';

class SomeModel {
  ticker = new Ticker({
    ticksPer: 1_000,
  });
}

someModel.ticker.start();

reaction(
  () => someModel.ticker.ticks,
  (ticks) => {
    console.info('ticks', ticks);
  },
);

Shared code for UI tabs

usage

import { TabManager } from 'mobx-shared-entities/tab-manager';

class SomeModel {
  tabs = new TabManager({
    tabs: [
      { id: '1' },
      { id: '2' },
    ]
  });
}

someModel.tabs.setActiveTab('1');

reaction(
  () => someModel.tabs.activeTabData,
  (activeTabData) => {
    console.info('activeTabData', activeTabData);
  },
);

Readme

Keywords

Package Sidebar

Install

npm i mobx-shared-entities

Weekly Downloads

1

Version

3.0.4

License

MIT

Unpacked Size

30.7 kB

Total Files

48

Last publish

Collaborators

  • js2me