Giter Site home page Giter Site logo

databridges-io / boilerplate.js.webworkers Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 31 KB

Databridges and Web workers.

Home Page: https://www.optomate.io

License: Apache License 2.0

JavaScript 100.00%
optomate databridges pubsub rpc websocket ws events realtime real-time webworkers

boilerplate.js.webworkers's Introduction

dataBridges and Web workers

dataBridges allows you deliver highly responsive real-time user interface to your customer using dataBridges channels along with event bindings.

When your web app has cpu consuming message manipulation such as encryption / decryption, data transformation before sending (publish) or after receiving (bind.channelEvents) real-time data, you can easily use Web Workers to run your JS functions. They are useful because they give you another thread to perform operations in. This can help free up the main thread and keep the app interactive.

dataBridges JavaScript SDK can be easily used inside web workers and supports both dedicated and shared worker.

dataBridges as dedicated workers

You will use dedicated workers if your app is a single instance app or each app page interface is completely independent from other (for example duplicating the running browser tab for example is not supported in your application).

We have developed a ready to use dbridge-dedicatedWorker.js boilerplate code for your usage.

dataBridges as shared workers

Shared workers are special web workers that can be accessed by multiple browser contexts like browser tabs, windows, iframes, or other workers, etc. All browser contexts must be within the same domain in accordance with the same-origin policy.

The difference between dedicated and shared workers is that dedicated workers can only be accessed by one script. Shared workers can be accessed by multiple scripts even if each page run inside different windows.

You will use shared worker if your app supports multiple browser tabs, windows, iframes and each of them consumes a global state updated by your application server using dataBridges channels or client functions. Also shared worker is useful to limit the number of dataBridges connection.

We have developed a ready to use dbridge-sharedWorker.js boilerplate code for your usage.

dataBridges web worker boilerplate

We have released fully functional boilerplate code for dedicated web workers (dbridge-dedicateWorker.js) and shared web worker (dbridge-sharedworker.js). โ€‹

  • Once the worker is instantiated, we can send channel subscription and unsubscription to the worker. The worker in turn will connect to the dataBridges network and manage the channel communication. it will emit back the Channel event messages back to the browser tabs, windows which have subscribed to the channels.
  • The worker will also send the state information (Online or Offline) back to tabs and windows.
  • Channel subscription is useful in the shared worker scenario as the application might open multiple tab / windows which might want to subscribe to different set of channels. Moreover the worker manages the multiplexing of same channel subscription across tabs and windows. โ€‹

boilerplate.js.webworkers's People

Contributors

optomate-tech avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.