Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.8.0 - refactor the Storage constructor() to take in an object instead #10

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ export type StorageCallbackMap = Record<string, StorageWatchCallback>

const hasWindow = typeof window !== "undefined"

export type StorageConfig = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should infer type instead. I will refactor this a bit.

storageArea: StorageAreaName,
secretKeyList: string[]
}

/**
* https://docs.plasmo.com/framework-api/storage
*/
Expand All @@ -38,10 +43,12 @@ export class Storage {

hasExtensionAPI = false

constructor(
storageArea = "sync" as StorageAreaName,
secretKeyList: string[] = []
) {
constructor(config: StorageConfig = {
storageArea: "sync" as StorageAreaName,
secretKeyList: []
}) {
const {storageArea, secretKeyList} = config;

this.#secretSet = new Set(secretKeyList)
this.#area = storageArea

Expand Down