Skip to content

Commit

Permalink
fix: useNow and types
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNoim committed Jan 21, 2023
1 parent d1f301c commit 6a86c77
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 22 deletions.
17 changes: 16 additions & 1 deletion deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { connection } from "./connection.ts";
import { connection } from "../hass/connection.ts";
import { configColl } from "../dep.ts";
import { reactive } from "../dep.ts";
import type { HassConfig } from "../dep.ts";
Expand Down
14 changes: 14 additions & 0 deletions reactive_home/src/composeables/useNow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ref } from "../dep.ts";
import type { Ref } from "../dep.ts";

export type UseNowOptions = { interval?: number };

export function useNow(options?: UseNowOptions) {
const value: Ref<Date> = ref(new Date());

setInterval(() => {
value.value = new Date();
}, options?.interval);

return value;
}
8 changes: 5 additions & 3 deletions reactive_home/src/dep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ export type {
ComputedRef,
} from "https://esm.noim.io/@vue/[email protected]";

export { useNow } from "./composeables/useNow.ts";

export {
useNow,
whenever,
extendRef,
refAutoReset,
Expand All @@ -35,11 +36,12 @@ export { Input as CliffyInput } from "https://deno.land/x/[email protected]/prompt/
export {
subMilliseconds,
subSeconds,
eachMinuteOfInterval,
subHours,
addHours,
} from "https://esm.noim.io/[email protected]?exports=subMilliseconds,subSeconds,eachMinuteOfInterval,subHours,addHours";
eachMinuteOfInterval,
} from "https://cdn.skypack.dev/[email protected]";

// @deno-types="https://raw.githubusercontent.com/Hypnos3/suncalc3/609d315d7787d15ca3f4643f8b121839e8333cee/suncalc.d.ts"
import SunCalc from "https://esm.noim.io/[email protected]";

import parse from "https://esm.noim.io/[email protected]";
Expand Down
4 changes: 2 additions & 2 deletions reactive_home/src/lib/sun.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useHassConfig } from "../hass/config.ts";
import { useNow } from "../dep.ts";
import { useHassConfig } from "../composeables/useConfig.ts";
import { useNow } from "../composeables/useNow.ts";
import { computed } from "../dep.ts";
import { eachMinuteOfInterval, subHours, addHours, SunCalc } from "../dep.ts";

Expand Down
16 changes: 1 addition & 15 deletions reactive_home/src/mod.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
export * from "./composeables/mapState.ts";
export * from "./composeables/useBoolean.ts";
export * from "./composeables/useLight.ts";
export * from "./composeables/useState.ts";
export * from "./composeables/useStateForDuration.ts";
export * from "./composeables/useNewBoolean.ts";
export * from "./composeables/useNewLight.ts";
export * from "./composeables/useLightMapping.ts";

export * from "./hass/config.ts";

export * from "./lib/light.ts";
export * from "./lib/sun.ts";
export * from "./lib/types.ts";
export * from "./lib/util.ts";
export * from "./public.ts";

export { computed, watch, unref, reactive, ref } from "./dep.ts";

Expand Down
22 changes: 22 additions & 0 deletions reactive_home/src/public.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Public API to expose without dep
*/

export * from "./composeables/mapState.ts";
export * from "./composeables/useBoolean.ts";
export * from "./composeables/useLight.ts";
export * from "./composeables/useState.ts";
export * from "./composeables/useStateForDuration.ts";
export * from "./composeables/useNewBoolean.ts";
export * from "./composeables/useNewLight.ts";
export * from "./composeables/useLightMapping.ts";
export * from "./composeables/useNow.ts";

export * from "./composeables/useConfig.ts";

export * from "./lib/light.ts";
export * from "./lib/sun.ts";
export * from "./lib/types.ts";
export * from "./lib/util.ts";

export { connection } from "./hass/connection.ts";

0 comments on commit 6a86c77

Please sign in to comment.