Skip to content

Commit

Permalink
Remove stateKey
Browse files Browse the repository at this point in the history
  • Loading branch information
goatslacker committed May 12, 2015
1 parent a9c35e0 commit 40830ea
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 70 deletions.
15 changes: 0 additions & 15 deletions docs/createStore.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,6 @@ Available configuration options:
`getState` receives the current state and returns a copy of it. You can override this function to provide your own implementation.

#### stateKey

`stateKey` is a string that controls where state should be defined at this particular store's level. For example:

```js
class TodoStore {
static config = {
stateKey: 'state'
}
constructor() {
this.state = { todos: {} }
}
}
```

#### onSerialize

`onSerialize` is also called before the store's state is serialized. You may optionally return an object, which will be used directly as the snapshot data for the store. If you do not return anything, the default, [`MyStore#getState()`](stores.md#storegetstate) is used for the snapshot data. See the [serialization](serialization.md) for an example.
Expand Down
25 changes: 0 additions & 25 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,31 +65,6 @@ This controls how store data is serialized in snapshots. By default alt uses `JS

This controls how store data is deserialized from snapshot/bootstrap data. By default alt uses `JSON.parse`, but you can provide your own function to deserialize data.

#### stateKey

`stateKey` is a string that controls where state should be defined at the store level. For example:

```js
var alt = new Alt({
stateKey: 'cherry'
});

class MyStore {
constructor() {
// state now goes in this.cherry
this.cherry = {
a: 1,
b: 2,
c: 3
};

// instance properties declared below do not go into state
this.isPrivate = 'yes'
this.yay = true
}
}
```

#### stateTransforms

This is an array of functions you can provide which will be executed every time `createStore` or `createUnsavedStore` is ran. It will iterate through the array applying each function to your store. This can be useful if you wish to perform any pre-processing or transformations to your store before it's created.
Expand Down
2 changes: 1 addition & 1 deletion src/alt/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export function createStoreFromClass(alt, StoreModel, key, ...argsForClass) {
new AltStore(
alt,
store,
store[alt.config.stateKey] || store[config.stateKey] || null,
typeof store.state === 'object' ? store.state : null,
StoreModel
),
utils.getInternalMethods(StoreModel),
Expand Down
2 changes: 0 additions & 2 deletions src/utils/ImmutableUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import Immutable from 'immutable'

function immutable(StoreModel) {
StoreModel.config = {
stateKey: 'state',

setState(currentState, nextState) {
this.state = nextState
return this.state
Expand Down
26 changes: 0 additions & 26 deletions test/custom-state-key-test.js

This file was deleted.

1 change: 0 additions & 1 deletion test/decorators-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export default {
'decorate store creation with args'() {
@createStore(alt, 1, 2, 3)
class StoreArgs {
static config = { stateKey: 'state' }
constructor(one, two, three) {
this.state = { one, two, three }
}
Expand Down

0 comments on commit 40830ea

Please sign in to comment.