Skip to content

Instantly share code, notes, and snippets.

@GrandSchtroumpf
Created April 12, 2018 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GrandSchtroumpf/110998868c6242d50adbac64b374c684 to your computer and use it in GitHub Desktop.
Save GrandSchtroumpf/110998868c6242d50adbac64b374c684 to your computer and use it in GitHub Desktop.
Import ngrx into our module
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { environment } from './../../environments/environment';
// Web3
import { WEB3 } from './tokens';
const Web3 = require('web3');
// Services
import { AccountsService } from './eth.services';
// NGRX
import { StoreModule } from '@ngrx/store';
import { EffectsModule } from '@ngrx/effects';
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
// MODULE FACTORY
@NgModule({
imports: [
CommonModule,
StoreModule.forRoot(...),
EffectsModule.forRoot([...]),
environment.production ? [] : StoreDevtoolsModule.instrument(),
],
providers: [AccountsService, {
provide: WEB3,
useFactory: () => new Web3(Web3.givenProvider || "ws://localhost:8546"),
}]
})
export class EthereumModule {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment