Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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