Skip to content

Commit 0950abc

Browse files
committed
refactor: Extract types out of store
1 parent be99042 commit 0950abc

5 files changed

Lines changed: 18 additions & 18 deletions

File tree

app/flags/flag.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import qs from "qs";
22

33
import { isRunningInBrowser } from "@/utils/is-running-in-browser";
44

5-
import FlagStore, { FlagName, FlagValue } from "./store";
5+
import FlagStore from "./store";
6+
import { FlagName, FlagValue } from "./types";
67

78
const FLAG_PREFIX = "flag__";
89

app/flags/ls-adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FlagName, FlagValue } from "./store";
1+
import { FlagName, FlagValue } from "./types";
22

33
export const prefix = "flag__";
44
export const getKey = (name: FlagName) => prefix + name;

app/flags/store.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
11
import mitt, { Emitter } from "mitt";
22

33
import lsAdapter from "./ls-adapter";
4-
5-
export type FlagValue = any;
6-
7-
export type FlagName =
8-
/** Whether we can search by termsets */
9-
| "search.termsets"
10-
/** Whether we can add dataset from shared dimensions */
11-
| "configurator.add-dataset.shared"
12-
/** Whether we can add a new dataset */
13-
| "configurator.add-dataset.new"
14-
/** Whether we can use the free canvas dashboard layout */
15-
| "layouter.dashboard.free-canvas"
16-
/** Whether we can use shared filters on dashboard layout */
17-
| "layouter.dashboard.shared-filters";
4+
import { FlagName, FlagValue } from "./types";
185

196
type Events = { change: string };
207
/**

app/flags/types.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export type FlagValue = any;
2+
3+
export type FlagName =
4+
/** Whether we can search by termsets */
5+
| "search.termsets"
6+
/** Whether we can add dataset from shared dimensions */
7+
| "configurator.add-dataset.shared"
8+
/** Whether we can add a new dataset */
9+
| "configurator.add-dataset.new"
10+
/** Whether we can use the free canvas dashboard layout */
11+
| "layouter.dashboard.free-canvas"
12+
/** Whether we can use shared filters on dashboard layout */
13+
| "layouter.dashboard.shared-filters";

app/flags/useFlag.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { useEffect, useState } from "react";
22

3-
import { FlagName } from "@/flags/store";
4-
53
import { flag } from "./flag";
4+
import { FlagName } from "./types";
65

76
export default function useFlag(name: FlagName) {
87
const [flagValue, setFlag] = useState(() => flag(name));

0 commit comments

Comments
 (0)