Skip to content

Commit

Permalink
refactor: add descriptive names to Symbols for better clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
tien committed Feb 23, 2025
1 parent 9de08c9 commit b082a63
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .changeset/thin-guests-exist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@reactive-dot/core": patch
"@reactive-dot/vue": patch
---

Added descriptive names to Symbols for better clarity.
2 changes: 1 addition & 1 deletion packages/core/src/providers/light-client/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getSmProvider } from "polkadot-api/sm-provider";
import { startFromWorker } from "polkadot-api/smoldot/from-worker";
import type { JsonRpcProvider } from "polkadot-api/ws-provider/web";

const getProviderSymbol = Symbol();
const getProviderSymbol = Symbol("getProvider");

export type LightClientProvider = {
[getProviderSymbol]: () => Promise<JsonRpcProvider>;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/symbols.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const idle = Symbol();
export const idle = Symbol("idle");

export const pending = Symbol();
export const pending = Symbol("pending");
2 changes: 1 addition & 1 deletion packages/core/src/utils/lazy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const empty = Symbol();
const empty = Symbol("empty");

export function lazy<T>(get: () => T) {
let value: T | typeof empty = empty;
Expand Down
14 changes: 9 additions & 5 deletions packages/vue/src/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,28 @@ import type { PolkadotSigner } from "@polkadot-api/polkadot-signer";
import type { ChainId, Config } from "@reactive-dot/core";
import type { InjectionKey, MaybeRefOrGetter, Ref, ShallowRef } from "vue";

export const configKey = Symbol() as InjectionKey<MaybeRefOrGetter<Config>>;
export const configKey = Symbol("config") as InjectionKey<
MaybeRefOrGetter<Config>
>;

export const chainIdKey = Symbol() as InjectionKey<MaybeRefOrGetter<ChainId>>;
export const chainIdKey = Symbol("chainId") as InjectionKey<
MaybeRefOrGetter<ChainId>
>;

export const signerKey = Symbol() as InjectionKey<
export const signerKey = Symbol("signer") as InjectionKey<
MaybeRefOrGetter<PolkadotSigner>
>;

/**
* @internal
*/
export const lazyValuesKey = Symbol() as InjectionKey<
export const lazyValuesKey = Symbol("lazyValues") as InjectionKey<
MaybeRefOrGetter<Map<string, ShallowRef<unknown>>>
>;

/**
* @internal
*/
export const mutationEventKey = Symbol() as InjectionKey<
export const mutationEventKey = Symbol("mutationEvent") as InjectionKey<
Ref<MutationEvent | undefined>
>;

0 comments on commit b082a63

Please sign in to comment.