0.109.0 • Published 8 days ago

reactant-share v0.109.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 days ago

reactant-share

Node CI

A framework for building shared web applications that support multiple windows.

Support

  • Shared Tab
  • Shared Worker
  • Detached window
  • iframe
  • Coworker
  • Any other data-transport based application port, such as WebRTC

Usage

npm install reactant-share
# or
yarn add reactant-share

Here is the counter example, it uses reactant-share ShareWorker mode:

  • app.view.tsx:
import React from 'react';
import {
  ViewModule,
  createApp,
  injectable,
  useConnector,
  action,
  state,
  spawn,
} from 'reactant-share';

@injectable({ name: 'counter' })
class Counter {
  @state
  count = 0;

  @action
  increase() {
    this.count += 1;
  }
}

@injectable()
export class AppView extends ViewModule {
  constructor(public counter: Counter) {
    super();
  }

  component() {
    const count = useConnector(() => this.counter.count);
    return (
      <button type="button" onClick={() => spawn(this.counter, 'increase', [])}>
        {count}
      </button>
    );
  }
}
  • index.tsx:
import { render } from 'reactant-web';
import { createSharedApp } from 'reactant-share';
import { AppView } from './app.view';

createSharedApp({
  modules: [],
  main: AppView,
  render,
  share: {
    name: 'SharedWorkerApp',
    port: 'client',
    type: 'SharedWorker',
    workerURL: 'worker.bundle.js',
  },
}).then((app) => {
  app.bootstrap(document.getElementById('app'));
});
  • worker.tsx:
import { createSharedApp } from 'reactant-share';
import { AppView } from './app.view';

createSharedApp({
  modules: [],
  main: AppView,
  render: () => {
    //
  },
  share: {
    name: 'SharedWorkerApp',
    port: 'server',
    type: 'SharedWorker',
  },
}).then((app) => {
  // renderless
});

Workflow

Workflow

  1. client App: spawn(this.counter, 'increase', [])
  2. server app: this.counter.increase()
  3. return value to current client app and sync state to all client apps

Examples

Documentation

You can visit reactant.js.org for more documentation.

0.109.0

8 days ago

0.108.0

8 days ago

0.107.0

9 days ago

0.106.0

2 months ago

0.105.0

2 months ago

0.104.0

2 months ago

0.103.0

4 months ago

0.102.0

4 months ago

0.101.0

5 months ago

0.99.0

5 months ago

0.100.0

5 months ago

0.98.0

5 months ago

0.87.0

7 months ago

0.95.0

6 months ago

0.97.0

5 months ago

0.91.0

6 months ago

0.93.0

6 months ago

0.88.0

7 months ago

0.90.0

6 months ago

0.96.0

6 months ago

0.94.0

6 months ago

0.89.0

7 months ago

0.86.0

7 months ago

0.85.0

8 months ago

0.81.0

10 months ago

0.83.0

10 months ago

0.84.0

8 months ago

0.80.0

10 months ago

0.82.0

10 months ago

0.79.0

10 months ago

0.78.0

1 year ago

0.74.0

1 year ago

0.76.0

1 year ago

0.72.0

1 year ago

0.77.0

1 year ago

0.73.0

1 year ago

0.75.0

1 year ago

0.62.0

2 years ago

0.64.0

2 years ago

0.60.0

2 years ago

0.59.0

2 years ago

0.57.0

2 years ago

0.70.0

1 year ago

0.67.0

1 year ago

0.69.0

1 year ago

0.63.0

2 years ago

0.65.0

2 years ago

0.61.0

2 years ago

0.58.0

2 years ago

0.71.0

1 year ago

0.66.0

2 years ago

0.68.0

1 year ago

0.55.0

2 years ago

0.53.0

2 years ago

0.51.0

2 years ago

0.56.0

2 years ago

0.54.0

2 years ago

0.52.0

2 years ago

0.43.0

2 years ago

0.20.0

2 years ago

0.41.0

2 years ago

0.19.0

2 years ago

0.38.0

2 years ago

0.36.0

2 years ago

0.34.0

2 years ago

0.17.0

2 years ago

0.32.0

2 years ago

0.30.0

2 years ago

0.29.0

2 years ago

0.48.0

2 years ago

0.27.0

2 years ago

0.46.0

2 years ago

0.25.0

2 years ago

0.44.0

2 years ago

0.23.0

2 years ago

0.42.0

2 years ago

0.21.0

2 years ago

0.40.0

2 years ago

0.39.0

2 years ago

0.37.0

2 years ago

0.35.0

2 years ago

0.33.0

2 years ago

0.18.0

2 years ago

0.31.0

2 years ago

0.50.0

2 years ago

0.28.0

2 years ago

0.49.0

2 years ago

0.26.0

2 years ago

0.47.0

2 years ago

0.24.0

2 years ago

0.45.0

2 years ago

0.22.0

2 years ago

0.16.0

2 years ago

0.15.0

2 years ago

0.14.0

2 years ago

0.13.1

3 years ago

0.13.0

3 years ago

0.12.0

3 years ago

0.11.0

3 years ago

0.10.1

3 years ago

0.10.0

3 years ago

0.9.0

3 years ago

0.8.1

3 years ago

0.8.0

3 years ago

0.8.2

3 years ago

0.7.1

3 years ago