Test code:

export class AppModule {
  constructor(events: EventService, client: AuthService) {
    const result$ = events.get(CartAddEntrySuccessEvent);
    result$.subscribe((event) = > console.log(event));

    client.getUserToken().subscribe((token) = > console.log('user token: ', token));

    client.getOccUserId().subscribe((id) = > console.log('id: ', id));

    client.getClientToken().subscribe((clientToken) = > console.log('Client token: ', clientToken));

    client.getClientToken().subscribe((clientToken) = > console.log('Client token: ', clientToken));

    client.isUserLoggedIn().subscribe((logged) = > console.log('user logged? ', logged));

    client.authorize('1'.'2'); }}Copy the code

All data structures are in this.store.source._value:

Return a (); There is a function inside:

GetUserToken is a memoized function, passing select, returning a selectorOperator, and passing pipe:

PipeFromArray, if the input argument has only one element, returns it directly.

$pathOrMapFn = pathOrMapFn = pathOrMapFn = pathOrMapFn

The MapOperator (_next) function calls project for the input value:

Next: Call pathOrMapFn:

Create Feature Selector named siteContext:

CreateFeatureSelector:

Args now for the content of siteContext state:

The whole semantics of code: implement the map and arrow function fn, the result is assigned to the args, perform memoizedProjector. Memoized function, at this time the args is input parameters.

More of Jerry’s original articles can be found in “Wang Zixi” :