diff --git a/examples/angular/package.json b/examples/angular/package.json index 8ec11f2b..c466bcff 100644 --- a/examples/angular/package.json +++ b/examples/angular/package.json @@ -23,7 +23,6 @@ "core-js": "^2.4.1", "express-http-proxy": "^0.11.0", "gun": "^0.7.2", - "gun-edge": "^0.8.8", "ngx-pipes": "^1.5.10", "rxjs": "^5.3.0", "underscore": "^1.8.3", diff --git a/examples/angular/src/app/app.component.ts b/examples/angular/src/app/app.component.ts index 3c1c8d34..a7411229 100644 --- a/examples/angular/src/app/app.component.ts +++ b/examples/angular/src/app/app.component.ts @@ -1,11 +1,10 @@ import { Component, OnInit } from '@angular/core'; -import { $rx } from 'gun-edge/edge/observable/rx'; import Gun from 'gun/gun'; import { Observable } from 'rxjs/Observable'; -import { GunDb } from 'app/gun.service'; import { omit } from 'underscore'; -import { Subject } from 'rxjs/Subject'; +import { GunDb } from 'app/gun.service'; +import { rx$ } from 'app/gun.helper'; @Component({ selector: 'app-root', @@ -16,7 +15,7 @@ export class AppComponent implements OnInit { newTodo = ''; todos = this.db.gun.get('todos'); - todos$: Observable = $rx(this.todos) + todos$: Observable = rx$(this.todos) .map(o => omit(o, '_')); constructor(private db: GunDb) { } diff --git a/examples/angular/src/app/gun.helper.ts b/examples/angular/src/app/gun.helper.ts new file mode 100644 index 00000000..b78d0c7a --- /dev/null +++ b/examples/angular/src/app/gun.helper.ts @@ -0,0 +1,9 @@ +import { Observable } from 'rxjs/Observable'; + +export function rx$(node): Observable { + return Observable.fromEventPattern( + // needed to clone the object because of #355 + h => node.on(v => h({ ...v })), + (_, s) => s.off() + ); +} \ No newline at end of file diff --git a/examples/angular/src/main.ts b/examples/angular/src/main.ts index 694a717a..348c032f 100644 --- a/examples/angular/src/main.ts +++ b/examples/angular/src/main.ts @@ -5,6 +5,9 @@ import { AppModule } from './app/app.module'; import { environment } from './environments/environment'; import 'rxjs/add/operator/startWith'; +import 'rxjs/add/operator/map'; + +import 'rxjs/add/observable/fromEventPattern'; if (environment.production) { enableProdMode();