Skip to content

Latest commit

 

History

History
34 lines (23 loc) · 1.28 KB

File metadata and controls

34 lines (23 loc) · 1.28 KB

Join the chat at https://gitter.im/scalecube-js/Lobby

This is part of scalecube-js project, see more at https://github.com/scalecube/scalecube-js
Full documentation

Cluster-browser

This package provides a default cluster implementation for browser. it uses native browser message event for creating the distributed environment.

Basic Usage

import { joinCluster } from '@scalecube/cluster-browser';

const clusterOptions = {
  seedAddress,
  address,
  itemsToPublish: [],
};

const cluster = joinCluster(clusterOptions);

// calling `getCurrentMembersData()`, will resolve with the distributed environment's latest state.
cluster.getCurrentMembersData().then(console.log); 

// on subscribe to `listen$()`, we will start getting emits of the distributed environment's latest state.
cluster.listen$().subscribe(console.log); 


// on calling `destroy()`, we will remove our metadata from the distributed environment. 
// also, it stops the cluster from sharing/publishing metadata.
cluster.destroy().then(console.log);