fix(angular): use new js-waku api
This commit is contained in:
parent
ef955e7133
commit
b80e8fcda7
|
@ -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<Waku>();
|
||||
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");
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue