Skip to content

Commit

Permalink
Merge pull request #3233 from storybooks/example-with-ngrx-store
Browse files Browse the repository at this point in the history
Add example for @ngrx/store
  • Loading branch information
Hypnosphi authored Mar 18, 2018
2 parents c60a6aa + 13f3366 commit 59eabba
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/angular-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@angular/forms": "^5.2.9",
"@angular/platform-browser": "^5.2.9",
"@angular/platform-browser-dynamic": "^5.2.9",
"@ngrx/store": "^5.2.0",
"core-js": "^2.4.1",
"rxjs": "^5.5.7",
"zone.js": "^0.8.20"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Storyshots ngrx|Store With component 1`] = `
<storybook-dynamic-app-root
cfr={[Function CodegenComponentFactoryResolver]}
data={[Function Object]}
target={[Function ViewContainerRef_]}
>
<storybook-comp-with-store>
<div>
Store is injected
</div>
</storybook-comp-with-store>
</storybook-dynamic-app-root>
`;

exports[`Storyshots ngrx|Store With template 1`] = `
<storybook-dynamic-app-root
cfr={[Function CodegenComponentFactoryResolver]}
data={[Function Object]}
target={[Function ViewContainerRef_]}
>
<ng-component>
<storybook-comp-with-store>
<div>
Store is injected
</div>
</storybook-comp-with-store>
</ng-component>
</storybook-dynamic-app-root>
`;
17 changes: 17 additions & 0 deletions examples/angular-cli/src/stories/ngrx-store.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { StoreModule } from '@ngrx/store';
import { storiesOf, moduleMetadata } from '@storybook/angular';
import { WithStoreComponent } from './ngrx/WithStoreComponent';

storiesOf('ngrx|Store', module)
.addDecorator(
moduleMetadata({
imports: [StoreModule.forRoot({})],
declarations: [WithStoreComponent],
})
)
.add('With component', () => ({
component: WithStoreComponent,
}))
.add('With template', () => ({
template: `<storybook-comp-with-store></storybook-comp-with-store>`,
}));
18 changes: 18 additions & 0 deletions examples/angular-cli/src/stories/ngrx/WithStoreComponent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Component } from '@angular/core';
import { Store } from '@ngrx/store';

@Component({
selector: 'storybook-comp-with-store',
template: '<div>{{this.getSotreState()}}</div>',
})
export class WithStoreComponent {
private store: Store<any>;

constructor(store: Store<any>) {
this.store = store;
}

getSotreState() {
return this.store === undefined ? 'Store is NOT injected' : 'Store is injected';
}
}
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@
lodash "^4.2.0"
to-fast-properties "^2.0.0"

"@ngrx/store@^5.2.0":
version "5.2.0"
resolved "https://registry.yarnpkg.com/@ngrx/store/-/store-5.2.0.tgz#627ed74c9cd95462930485d912a557117b23903e"

"@ngtools/json-schema@1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@ngtools/json-schema/-/json-schema-1.2.0.tgz#06e5ecd29e9a37d260a447dd873ea2becd228c4f"
Expand Down

0 comments on commit 59eabba

Please sign in to comment.