Skip to content

Commit

Permalink
bump
Browse files Browse the repository at this point in the history
  • Loading branch information
zoe-codez committed Oct 31, 2024
1 parent e3e6614 commit 7547ce8
Show file tree
Hide file tree
Showing 9 changed files with 516 additions and 372 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "@digital-alchemy/hass",
"repository": "https://github.com/Digital-Alchemy-TS/hass",
"homepage": "https://docs.digital-alchemy.app",
"version": "24.10.1",
"version": "24.10.2",
"description": "Typescript APIs for Home Assistant. Includes rest & websocket bindings",
"scripts": {
"build": "rm -rf dist/; tsc",
Expand Down Expand Up @@ -56,10 +56,10 @@
},
"license": "MIT",
"devDependencies": {
"@cspell/eslint-plugin": "^8.15.4",
"@cspell/eslint-plugin": "^8.15.5",
"@digital-alchemy/core": "^24.10.8",
"@digital-alchemy/synapse": "^24.9.4",
"@digital-alchemy/type-writer": "^24.10.1",
"@digital-alchemy/type-writer": "^24.10.2",
"@eslint/compat": "^1.2.2",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.13.0",
Expand Down
36 changes: 26 additions & 10 deletions src/extensions/events.extension.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TServiceParams } from "@digital-alchemy/core";
import { is, TServiceParams } from "@digital-alchemy/core";

import {
AREA_REGISTRY_UPDATED,
Expand All @@ -11,15 +11,31 @@ import {
ZONE_REGISTRY_UPDATED,
} from "../helpers";

export function Events({ event }: TServiceParams): HassEventsService {
export function EventsService({ event }: TServiceParams): HassEventsService {
return {
onAreaRegistryUpdate: (callback: SimpleCallback) => event.on(AREA_REGISTRY_UPDATED, callback),
onDeviceRegistryUpdate: (callback: SimpleCallback) =>
event.on(DEVICE_REGISTRY_UPDATED, callback),
onEntityRegistryUpdate: (callback: SimpleCallback) =>
event.on(ENTITY_REGISTRY_UPDATED, callback),
onFloorRegistryUpdate: (callback: SimpleCallback) => event.on(FLOOR_REGISTRY_UPDATED, callback),
onLabelRegistryUpdate: (callback: SimpleCallback) => event.on(LABEL_REGISTRY_UPDATED, callback),
onZoneRegistryUpdate: (callback: SimpleCallback) => event.on(ZONE_REGISTRY_UPDATED, callback),
onAreaRegistryUpdate: (callback: SimpleCallback) => {
event.on(AREA_REGISTRY_UPDATED, callback);
return is.removeFn(() => event.removeListener(AREA_REGISTRY_UPDATED, callback));
},
onDeviceRegistryUpdate: (callback: SimpleCallback) => {
event.on(DEVICE_REGISTRY_UPDATED, callback);
return is.removeFn(() => event.removeListener(DEVICE_REGISTRY_UPDATED, callback));
},
onEntityRegistryUpdate: (callback: SimpleCallback) => {
event.on(ENTITY_REGISTRY_UPDATED, callback);
return is.removeFn(() => event.removeListener(ENTITY_REGISTRY_UPDATED, callback));
},
onFloorRegistryUpdate: (callback: SimpleCallback) => {
event.on(FLOOR_REGISTRY_UPDATED, callback);
return is.removeFn(() => event.removeListener(FLOOR_REGISTRY_UPDATED, callback));
},
onLabelRegistryUpdate: (callback: SimpleCallback) => {
event.on(LABEL_REGISTRY_UPDATED, callback);
return is.removeFn(() => event.removeListener(LABEL_REGISTRY_UPDATED, callback));
},
onZoneRegistryUpdate: (callback: SimpleCallback) => {
event.on(ZONE_REGISTRY_UPDATED, callback);
return is.removeFn(() => event.removeListener(ZONE_REGISTRY_UPDATED, callback));
},
};
}
Loading

0 comments on commit 7547ce8

Please sign in to comment.