Skip to content

Allow initial state function for AoT compatibility#59

Merged
brandonroberts merged 1 commit into
ngrx:masterfrom
bfricka:feature/initial-state-fn
Jul 9, 2017
Merged

Allow initial state function for AoT compatibility#59
brandonroberts merged 1 commit into
ngrx:masterfrom
bfricka:feature/initial-state-fn

Conversation

@bfricka

@bfricka bfricka commented Jul 4, 2017

Copy link
Copy Markdown
Contributor

resolves #51

Comment thread docs/store/api.md Outdated
/// Pretend this is dynamically injected at runtime
const initialStateFromSomewhere = { counter: 3 };

/// Static static

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

should be Static state i guess.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed thanks

@bfricka bfricka force-pushed the feature/initial-state-fn branch from 9da06fd to 2087926 Compare July 4, 2017 06:59
@bfricka

bfricka commented Jul 4, 2017

Copy link
Copy Markdown
Contributor Author

FYI, tests are all passing, but coveralls is throwing a fit.

Comment thread docs/store/api.md Outdated
const initialState = { counter: 2 };

/// In this function dynamic state slices, if they exist, will overwrite static state at runtime.
const getInitialState = () => ({...initialState, ...initialStateFromSomewhere});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should be exported and a plain function instead of a arrow function for AOT support

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@bfricka bfricka force-pushed the feature/initial-state-fn branch from 2087926 to f5ac836 Compare July 5, 2017 22:53
@brandonroberts brandonroberts self-assigned this Jul 8, 2017
@brandonroberts brandonroberts merged commit 1a166ec into ngrx:master Jul 9, 2017
@brandonroberts

Copy link
Copy Markdown
Member

Thanks!

@bfricka bfricka deleted the feature/initial-state-fn branch July 10, 2017 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accept initialState function to allow dynamic initial state in AoT

3 participants