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 * as operators from 'rxjs/operators'; | |
export default function patchOperators(useOriginals = false) { | |
if (useOriginals === false) { | |
return new Proxy(operators, { | |
get: function(target, prop) { | |
const original = (target as any)[prop]; | |
if (typeof original === 'function') { | |
return function(...args: any[]) { | |
const result = original(...args); |
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 { CommonModule } from "@angular/common"; | |
import { NgModule } from "@angular/core"; | |
import { FormsModule } from "@angular/forms"; | |
import { RouterModule, Routes } from "@angular/router"; | |
import { StoreModule } from "actionstack"; | |
import { HeroService } from '../hero.service'; | |
import { HeroDetailsComponent } from './hero-details.component'; | |
import { reducer, slice } from "./hero-details.slice"; | |
const routes: Routes = [ |
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 { NgModule } from '@angular/core'; | |
import { FormsModule } from '@angular/forms'; | |
import { BrowserModule } from '@angular/platform-browser'; | |
import { AppComponent } from './app.component'; | |
import { Action, StoreModule, measure } from 'actionstack'; | |
import { AppRoutingModule } from './app-routing.module'; | |
import { MessagesModule } from './messages/messages.module'; | |
@NgModule({ | |
imports: [ |
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 { CommonModule } from '@angular/common'; | |
import { Component, OnInit } from '@angular/core'; | |
import { RouterModule } from '@angular/router'; | |
import { Slice } from 'actionstack'; | |
import { Observable } from 'rxjs'; | |
import { Hero } from '../hero'; | |
import { HeroService } from './../hero.service'; | |
import { loadHeroes, reducer, selectTopHeroes, slice } from './dashboard.slice'; | |
@Component({ |
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 { Action, action } from "actionstack"; | |
import { map } from "rxjs"; | |
import { Hero } from "../hero"; | |
export const slice = "heroes"; | |
export const getHeroesRequest = action("GET_HEROES_REQUEST", (heroes: Hero[]) => ({heroes})); | |
export const getHeroesSuccess = action("GET_HEROES_SUCCESS", (heroes: Hero[]) => ({heroes})); | |
export const loadHeroes = (action$, state$, { heroService }: any) => { |
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 { Action, action } from "actionstack"; | |
import { firstValueFrom } from "rxjs"; | |
import { Hero } from "../hero"; | |
export const slice = "hero-details"; | |
export const loadHeroRequest = action('LOAD_HERO_REQUEST'); | |
export const loadHeroSuccess = action('LOAD_HERO_SUCCESS', (hero: Hero) => ({ hero })); | |
export const loadHeroFailure = action('LOAD_HERO_FAILURE', (error: Error) => ({ error })); |
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 { featureSelector, selector } from "actionstack"; | |
export const slice = "messages"; | |
export const feature = featureSelector(slice); | |
export const selectMessages = selector(feature, state => state.messages); | |
export const selectMessageCount = selector(feature, state => state.messages.length); | |
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 { Component, OnDestroy, OnInit } from '@angular/core'; | |
import { Store } from 'actionstack'; | |
import { Subscription } from 'rxjs'; | |
import { Hero } from '../hero'; | |
import { selectHeroes } from './heroes.slice'; | |
@Component({ | |
selector: 'app-heroes', | |
templateUrl: './heroes.component.html', |
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 { Component, OnDestroy, OnInit } from '@angular/core'; | |
import { Store } from 'actionstack'; | |
import { getHeroesRequest } from './heroes.slice'; | |
@Component({ | |
selector: 'app-heroes', | |
templateUrl: './heroes.component.html', | |
styleUrls: ['./heroes.component.css'] | |
}) | |
export class HeroesComponent implements OnInit, OnDestroy { |
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 { Action, store, measure } from 'actionstack'; | |
const storeInstance = store({ | |
middlewares: [measure], | |
reducer: (state: any = {}, action: Action<any>) => state, | |
dependencies: {}, | |
strategy: "concurrent", | |
}); |
NewerOlder