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

react-redux-chromecast-sender

v0.0.3

Published

React/Redux helpers for Chromecast communication (sender)

Downloads

6

Readme

react-redux-chromecast

BETA: Do not use in production

Helper to communicate with the Google Chromecast, keeping current state in redux.

Prerequisites

  1. In order to communicate with the Chromecast the Google Cast extension from Google must be installed. Install it from the Chrome Web Store.
  2. You need to register your Chromecast for development mode. This has a one-time fee of $5. Register at the Google Cast SDK Console.
  3. Create a new app and write down the applicationId

For more detailed instructions follow the guide in the Cast developer documentation.

Usage

Note: For universal applications only include the cast middleware on the client

After installing you probably want to create some middleware to translate the raw messages to whatever is applicable to your application.

Sender

Store configuration

import {createStore, applyMiddleware} from 'redux';
import {castSender} from 'react-redux-chromecast';

// sender
const middleware = [castSender(
  '<app id>',   // app id assigned by Google
  '<namespace>' // namespace for communication (namespace must match on receiver)
)];
const store = applyMiddleware(...middleware)(createStore);

Add the sender script to the page

<script async src="//www.gstatic.com/cv/js/sender/v1/cast_sender.js" charset="utf-8"></script>

Events

All events are fired as redux actions.

Constants:

import {
  API_AVAILABLE,
  RECEIVER_AVAILABLE,
  ...
} from 'react-redux-chromecast';

API_AVAILABLE

Chromecast API is available (will only work in Chrome with the Chromecast extension installed)

API_UNAVILABLE

Chromecast API not available (e.g., browser not supported)

RECEIVER_AVAILABLE

Chromecasts detected. Use this to show the chromecast button.

Note that this happens asynchronously and can occur later in the lifecycle of the app, for instance if the user changes wifi network to the same one as the Chromecast is on.

RECEIVER_UNAVAILABLE

No Chromecasts detected. Use this to hide the button.

Note that even if chromecasts were detected before they can disappear. This action fires if this happens.

SESSION_CONNECTING

Connecting to Chromecast. Show an animated chromecast icon.

SESSION_CONNECTED

Session established. Show the lit icon.

SESSION_DISCONNECTING

User has requested to disconnect the session.

SESSION_DISCONNECTED

Chromecast is not connected.

SESSION_CONNECT_ERROR

An error occurred while trying to connect.

SESSION_DISCONNECT_ERROR

An error occurred while trying to disconnect.

MESSAGE_SENDING

A message is being sent.

MESSAGE_SENT

A message was succesfully sent.

MESSAGE_ERROR

An error occurred while trying to send a message.

MSG_RECEIVED

A message was received.

Commands

Commands to Chromecast as triggered by firing redux actions.

Constants:

import {
  SESSION_CONNECT,
  SESSION_DISCONNECT,
  ...
} from 'react-redux-chromecast/commands';

SESSION_CONNECT

Try to establish a connection.

Fires actions asynchronously:

SESSION_CONNECT
|- Event: SESSION_CONNECTING
...
|- Success
|  |- SESSION_CONNECTED
|- Failed
   |- SESSION_CONNECT_ERROR

SESSION_DISCONNECT

Disconnect current session. Doesn't do anything if not connected.

Fires actions asynchronously:

SESSION_DISCONNECT
|- Event: SESSION_DISCONNECTING
...
|- Success
|  |- SESSION_DISCONNECTED
|- Failed
   |- SESSION_DISCONNECT_ERROR