multithread-it
A components oriented virtual dom in a worker rendering solution
Last updated 3 years ago by kepennar .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install multithread-it 
SYNC missed versions from official npm registry.

Multithread-it

A components oriented virtual dom in a worker rendering solution

Multithread-it help you writing web components wich do not block UI. This component will be rendered in a web-worker.

Components are written with virtual-dom and JSX.

Events are propagated from the UI thread to the application worker using an abstraction over Redux.

Example

Your component is the composition of two elements.

A Component working in the application WebWorker

import { MultithreadItComponent } from 'multithread-it';

class Component extends MultithreadItComponent {
  _label; 

  onInit() {
    this.watch(
      state => state.label,
      label => this._label = label
    );
  }

  render() {
    return (
      <div>
        {this._label}
        <button data-click="EVENT_CLICK">-</button>
      </div>
    );
  }
}

An EventsHandlers listening to component events in the UI-thread

import { MultithreadItEventsHandler } from 'multithread-it';

class EventsHandlers  extends MultithreadItEventsHandler {
  constructor(workerStore) {
    super(workerStore);

    this.addEventHandlers(
      'click',
      e => this._click(e)
    );
  }

    _click(e) {
    const target = e.target;
    if (target['data-click'] === 'EVENT_CLICK') {
      e.preventDefault();
      this._worker.dispatchEvent('click', 'clicked');
    }
  }
}

Then, in the application WebWorker a Redux reducer will process events.


function label(state = 'Initialized', action) {
  switch (action.type) {
    case 'click':
      return state = action.data;
    default:
      return state;
  }
}

For more informations about how Multithread-it should be used. Have a look to examples:

Current Tags

  • 0.0.5                                ...           beta (4 years ago)
  • 0.1.3                                ...           latest (3 years ago)

13 Versions

  • 0.1.3                                ...           3 years ago
  • 0.1.2                                ...           3 years ago
  • 0.1.1                                ...           3 years ago
  • 0.1.0                                ...           3 years ago
  • 0.0.9                                ...           3 years ago
  • 0.0.8                                ...           3 years ago
  • 0.0.7                                ...           4 years ago
  • 0.0.6                                ...           4 years ago
  • 0.0.5                                ...           4 years ago
  • 0.0.4                                ...           4 years ago
  • 0.0.3                                ...           4 years ago
  • 0.0.2                                ...           4 years ago
  • 0.0.1                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (10)
Dev Dependencies (27)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |