How to use where clause in Knex
Create refunds with Stripe
Load HTML with Cheerio
How to send POST request with Axios
Find intersection of array in Lodash
Powered by Official white Bloop logo with a period

Terms / Privacy / Search / Support

  • import { NgModule, InjectionToken } from '@angular/core';
    import { StoreModule, StoreConfig } from '@ngrx/store';
    import { SomeService } from './some.service';
     
    import * as fromFeature from './reducers';
     
    export const FEATURE_CONFIG_TOKEN = new InjectionToken<StoreConfig<fromFeature.State>>('Feature Config');
     
    export function getConfig(someService: SomeService): StoreConfig<fromFeature.State> {
      // return the config synchronously.
      return {
        initialState: someService.getInitialState(),
     
        metaReducers: [
          fromFeature.loggerFactory(someService.loggerConfig())
        ]
      };
    }
     
    @NgModule({
      imports: [StoreModule.forFeature(fromFeature.featureKey, fromFeature.reducers, FEATURE_CONFIG_TOKEN)],
      providers: [
        {
          provide: FEATURE_CONFIG_TOKEN,
          deps: [SomeService],
          useFactory: getConfig,
        },
      ],
    })
    export class FeatureModule {}
    Docs
  • import { InjectionToken } from '@angular/core';
    
    export const TITLE = new InjectionToken<string>('title');
    Docs
  • import { NgModule, InjectionToken } from '@angular/core';
    import { StoreModule, ActionReducerMap } from '@ngrx/store';
     
    import * as fromFeature from './reducers';
     
    export const FEATURE_REDUCER_TOKEN = new InjectionToken<
      ActionReducerMap<fromFeature.State>
    >('Feature Reducers');
     
    export function getReducers(): ActionReducerMap<fromFeature.State> {
      // map of reducers
      return {};
    }
     
    @NgModule({
      imports: [StoreModule.forFeature(fromFeature.featureKey, FEATURE_REDUCER_TOKEN)],
      providers: [
        {
          provide: FEATURE_REDUCER_TOKEN,
          useFactory: getReducers,
        },
      ],
    })
    export class FeatureModule {}
    Docs
  • import { InjectionToken } from '@angular/core';
    
    export const APP_CONFIG = new InjectionToken<AppConfig>('app.config');
    Docs
  • import {Component, NgModule} from '@angular/core'
    import {render, screen} from '@testing-library/angular'
    import {ngMocks} from 'ng-mocks'
    
    @Component({
      selector: 'app-parent-component',
      template: '<app-child-component></app-child-component>',
    })
    class ParentComponent {}
    
    @Component({
      selector: 'app-child-component',
      template: '<p>Child component</p>',
    })
    class ChildComponent {}
    
    @NgModule({
      declarations: [ParentComponent, ChildComponent],
    })
    export class AppModule {}
    
    describe('ParentComponent', () => {
      it('should not render ChildComponent when shallow rendering', async () => {
        const dependencies = ngMocks.guts(null, AppModule, ParentComponent)
    
        await render(ParentComponent, dependencies)
    
        expect(screen.queryByText('Child component')).toBeNull()
      })
    })
    Docs
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples