-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from ice-lab/fix-indent
chore: fix indent
- Loading branch information
Showing
6 changed files
with
191 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
import Store from './store'; | ||
|
||
export default class Icestore { | ||
private stores: {[namespace: string]: Store} = {}; | ||
private stores: {[namespace: string]: Store} = {}; | ||
|
||
public registerStore(namespace: string, bindings: object): Store { | ||
if (this.stores[namespace]) { | ||
throw new Error(`Namespace have been used: ${namespace}.`); | ||
} | ||
|
||
this.stores[namespace] = new Store(bindings); | ||
return this.stores[namespace]; | ||
public registerStore(namespace: string, bindings: object): Store { | ||
if (this.stores[namespace]) { | ||
throw new Error(`Namespace have been used: ${namespace}.`); | ||
} | ||
|
||
private getModel(namespace: string): Store { | ||
const store: Store = this.stores[namespace]; | ||
if (!store) { | ||
throw new Error(`Not found namespace: ${namespace}.`); | ||
} | ||
return store; | ||
} | ||
this.stores[namespace] = new Store(bindings); | ||
return this.stores[namespace]; | ||
} | ||
|
||
public useStore(namespace: string): object { | ||
return this.getModel(namespace).useStore(); | ||
private getModel(namespace: string): Store { | ||
const store: Store = this.stores[namespace]; | ||
if (!store) { | ||
throw new Error(`Not found namespace: ${namespace}.`); | ||
} | ||
return store; | ||
} | ||
|
||
public useStores(namespaces: string[]): object[] { | ||
return namespaces.map(namespace => this.useStore(namespace)); | ||
} | ||
public useStore(namespace: string): object { | ||
return this.getModel(namespace).useStore(); | ||
} | ||
|
||
public useStores(namespaces: string[]): object[] { | ||
return namespaces.map(namespace => this.useStore(namespace)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.