- Users want to compose reducer tree across modules
- Idea of a single reducer function makes it difficult for the library to dynamically augment the shape of the state tree
- Turning control over to the library to build the root reducer limits the use of meta-reducers
- Feature modules may inadvertently collide with the state of the root module
- Library authors may want to leverage @ngrx/store in their projects and provide an easy way
First you have to define the scalar type in the GraphQL schema:
scalar Date
Then you have to provide a resolver for the scalar type. Here's an example implementation using Luxon:
import { DateTime } from 'luxon';
makeExecutableSchema({
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
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 | |
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 | |
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 | |
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 | |
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 | |
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 | |
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 | |
255 255 255 255 115 32 168 255 255 92 32 56 32 255 255 255 | |
255 255 255 32 32 32 115 255 32 69 59 44 255 255 255 255 | |
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 |
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
import { Observable, Observer } from 'rxjs'; | |
import { createSelector, MemoizedSelector } from '@ngrx/store'; | |
import { createEntityAdapter } from '@ngrx/entity'; | |
export interface View<T> extends Observable<T> { | |
isView: true; | |
release(): void; | |
} | |
export interface Value<T> extends View<T> { |
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
export class BookEffects { | |
@Effect() updateBook$ = this.actions$.pipe( | |
ofType(INPUT_ACTION_TYPE), | |
groupBy( | |
action => action.bookId, | |
action => action, | |
action$ => action$.pipe( | |
timeoutWith(15000, Observable.empty()), | |
ignoreElements(), | |
), |
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
export class BookEffects { | |
@Effect() deleteBook$ = this.action$.pipe( | |
ofType(INPUT_ACTION_TYPE), | |
mergeMap(action => this.bookService.deleteBook(action.bookId)), | |
); | |
} |
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
export class BookEffects { | |
@Effect() getOneBook$ = this.action$.pipe( | |
ofType(INPUT_ACTION_TYPE), | |
groupBy( | |
action => action.bookId, | |
action => action.bookId, | |
bookId$ => bookId$.pipe( | |
timeoutWith(15000, Observable.empty(), | |
ignoreElements(), | |
), |
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
groupBy( | |
/** | |
* Select groups by their `bookId` | |
*/ | |
action => action.bookId, | |
/** | |
* Map each action to the `bookId` for convenience | |
*/ | |
action => action.bookId, | |
/** |
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
export class BookEffects { | |
@Effect() getOneBook$ = this.actions$.pipe( | |
// Step 1 Type: Observable<InputActionType> | |
ofType(INPUT_ACTION_TYPE), | |
// Step 2 Type: Observable<Observable<InputActionType>> | |
groupBy(action => action.bookId), | |
// Step 3 Type: Observable<Observable<BookModel>>, | |
map(action$ => action$.pipe( | |
exhaustMap(action => this.bookService.getOne(action.bookId), | |
)), |
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
export class BookEffects { | |
@Effect() getOneBook$ = this.actions$.pipe( | |
ofType(INPUT_ACTION_TYPE), | |
exhaustMap(action => this.booksService.getOne(action.bookId)), | |
); | |
} |
NewerOlder