npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@100mslive/hms-video-store

v0.12.24

Published

@100mslive Core SDK which abstracts the complexities of webRTC while providing a reactive store for data management with a unidirectional data flow

Downloads

110,991

Readme

100ms Reactive Store

NPM Test Bundle Size Tree shaking

Architecture

This is an addon to the core sdk provided by 100ms. It abstracts away the intricacies of data management and provides a flux based reactive data store where data flows in only one direction.

The complexity of managing the state of a room is not a trivial task and can spiral out of control very fast. For example, multiple UI components can be interested in a simple data point such as whether the user is currently muted. The mute action itself can be taken from multiple different places in the UI or even by a remote participant. Local states and improper handling of actions or missing corner cases, state duplication etc. have a high potential to make the data mutually inconsistent and out of sync with the source of truth.

This is an opinionated reactive layer on top of our core sdk which takes some control in order to provide an even easier usability and integration experience. Your UI components can forget about local states, and tracking what actions are happening, instead focusing only on giving the best possible experience to the end users.

There are two important pieces, store for what you want to show and actions for what you want to do -

  1. Store - The core store interface for reading data usually using selectors. The store acts as a single source of truth for any data related to the room. There are two exposed functions -
    • getState(selector) -> get the current state of the UI, true at the time of function call
    • subscribe(callback, selector) -> subscribe to a portion of the state selected by the passed in selector such that whenever the portion changes, the passed in callback is notified.
  2. Actions - The actions interface for dispatching actions which in turn may reach out to server and update the store. Check the interface with detailed doc here.

We also provide optimized and efficient selectors for most common use cases. These are available in this folder.

Important Note: The data received from either getState or Subscribe is immutable, the object received is frozen, and it is not allowed to mutate it. You'll get an error if you try to mutate this data in any way. Immutability of the store is how we ensure it to be consistent and reflect the truth at any point of time.

Installation

yarn add @100mslive/hms-video-store

How To Use

const hms = new HMSReactiveStore();
const hmsActions = hms.getHMSActions();
const hmsStore = hms.getStore();

const toggleAudio = () => {
    const isEnabled = hmsStore.getState(selectIsLocalAudioEnabled);
    hmsActions.setLocalAudioEnabled(!isEnabled);
}

const onSpeakerUpdate = (speaker, prevSpeaker) => {
    console.log("speaker changed from - ", prevSpeaker, ", to - ", speaker);
}

hmsStore.subscribe(onSpeakerUpdate, selectDominantSpeaker);

Framework specific wrappers

Most of the popular javascript frameworks are reactive in nature and have some kind of associated concept which can simplify development further. We plan to provide a few framework specific wrappers as well for smoother integration.

React

We provide two hooks one for reading for the store and another for taking actions. We provide a HMSRoomProvider component which takes care of initialization and making these hooks available to your UI components.

function join() {
    const isConnected = useHMSStore(selectIsConnectedToRoom);
    const hmsActions = useHMSActions();

    return <>
        {
            !isConnected &&
            <Button onClick={() => hmsActions.join()}>Join</Button>
        }
    </>
}

Out of Box Support for Redux Devtools Extension

Store State

Store State

Store Graph

Store State

Refer to docs for more detailed guide