github home-assistant/home-assistant-js-websocket 3.2.0

latest releases: 9.5.0, 9.4.0, 9.3.0...
6 years ago

Now possible to get collection objects, instead of just subscribing to them.

// Will only initialize one collection per connection.
getCollection<State>(
  conn: Connection,
  key: string,
  fetchCollection: (conn: Connection) => Promise<State>,
  subscribeUpdates: (
    conn: Connection,
    store: Store<State>
  ) => Promise<UnsubscribeFunc>,
): Collection<State>

// Returns object with following type
class Collection<State> {
  state: State;
  async refresh(): Promise<void>;
  subscribe(subscriber: (state: State) => void): UnsubscribeFunc;
}

You can also import the service, config and entities collections:

import { entitiesColl, servicesColl, configColl } from 'home-assistant-js-websocket';

Commits

Don't miss a new home-assistant-js-websocket release

NewReleases is sending notifications on new releases.