diff --git a/relay-angular-chat/src/app/waku.service.ts b/relay-angular-chat/src/app/waku.service.ts index 1f8e344..515afc8 100644 --- a/relay-angular-chat/src/app/waku.service.ts +++ b/relay-angular-chat/src/app/waku.service.ts @@ -1,27 +1,30 @@ -import { Injectable } from '@angular/core'; -import { Waku } from 'js-waku'; -import { BehaviorSubject, Subject } from 'rxjs'; +import { Injectable } from "@angular/core"; +import { Waku } from "js-waku"; +import { BehaviorSubject, Subject } from "rxjs"; +import { createWaku } from "js-waku/lib/create_waku"; +import { waitForRemotePeer } from "js-waku/lib/wait_for_remote_peer"; @Injectable({ - providedIn: 'root' + providedIn: "root", }) export class WakuService { - private wakuSubject = new Subject(); public waku = this.wakuSubject.asObservable(); - private wakuStatusSubject = new BehaviorSubject(''); + private wakuStatusSubject = new BehaviorSubject(""); public wakuStatus = this.wakuStatusSubject.asObservable(); - constructor() { } + constructor() {} init() { - Waku.create({ bootstrap: { default: true } }).then(waku => { - this.wakuSubject.next(waku); - this.wakuStatusSubject.next('Connecting...'); + createWaku({ defaultBootstrap: true }).then((waku) => { + waku.start().then(() => { + this.wakuSubject.next(waku); + this.wakuStatusSubject.next("Connecting..."); - waku.waitForRemotePeer().then(() => { - this.wakuStatusSubject.next('Connected'); + waitForRemotePeer(waku).then(() => { + this.wakuStatusSubject.next("Connected"); + }); }); }); } diff --git a/relay-angular-chat/src/main.ts b/relay-angular-chat/src/main.ts index c7b673c..38fa725 100644 --- a/relay-angular-chat/src/main.ts +++ b/relay-angular-chat/src/main.ts @@ -1,12 +1,15 @@ -import { enableProdMode } from '@angular/core'; -import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { enableProdMode } from "@angular/core"; +import { platformBrowserDynamic } from "@angular/platform-browser-dynamic"; -import { AppModule } from './app/app.module'; -import { environment } from './environments/environment'; +import { AppModule } from "./app/app.module"; +import { environment } from "./environments/environment"; + +import "zone.js"; if (environment.production) { enableProdMode(); } -platformBrowserDynamic().bootstrapModule(AppModule) - .catch(err => console.error(err)); +platformBrowserDynamic() + .bootstrapModule(AppModule) + .catch((err) => console.error(err));