Skip to content

3.2.0

Choose a tag to compare

@release-drafter release-drafter released this 03 Nov 20:42
· 540 commits to master since this release

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