How to use driver-worker - 2 common examples

To help you get started, we’ve selected a few driver-worker 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 alibaba / rax / packages / miniapp-framework-web / src / worker / Client.js View on Github external
setup() {
    const { createElement, render } = this.raxInstance;
    const driver = this.driver = createDriver({
      postMessage: this.sendMessageToRenderer,
      addEventListener: this.addClientEvent,
    });
    driver.setDeviceWidth(global[MINIAPP_ENV].windowWidth);

    const component = this.component = this.instantiatePage();
    // 页面加载时触发
    this.emitEvent('load', this.pageQuery);
    render(createElement(component, {}), null, {
      driver,
    });

    // 初始化 ready 事件, after render
    this.emitEvent('ready', {});
    global[CURRENT_CLIENT_ID] = this.clientId;
  }
github alibaba / rax / packages / mp-runtime / src / __tests__ / component.js View on Github external
it('should render style once', (done) => {
    function renderFactory(Rax) {
      return function(data) {
        return createElement('view', {
          className: 'foo',
        });
      };
    }
    const cssText = '.foo { color: red; }';
    const Comp = createComponent(renderFactory, Rax, {}, 'path/to/component', cssText);

    global.setImmediate = null;
    const driver = createWorkerDriver({
      postMessage(message) {
        expect(message).toMatchSnapshot();
        done();
      },
      addEventListener() {},
    });

    class Page extends Rax.Component {
      static contextTypes = { $page: null };

      getChildContext() {
        const $page = {
          vnode: { _document: driver.document }
        };
        return { $page };
      }

driver-worker

Worker driver for Rax

BSD-3-Clause
Latest version published 3 years ago

Package Health Score

57 / 100
Full package analysis

Popular driver-worker functions

Similar packages