ag-gun
v0.0.6
Published
Angular wrapper for Gun
Downloads
7
Readme
ag-Gun
Angular 6+ wrapper for Gun, a realtime, distributed, offline-first, graph database engine. Support server-side rendering.
GUN is a small, easy, and fast data sync and storage system that runs everywhere JavaScript does. The aim of GUN is to let you focus on the data that needs to stored, loaded, and shared in your app without worrying about servers, network calls, databases, or tracking offline changes or concurrency conflicts.
Install
npm i ag-gun --save
API
The AgGun
service is a wrapper around the native Gun API's
:
.opt(options)
.get(key)
.put(data)
.set(data)
.back()
.map(callback)
.open()
.on()
.once()
.list()
( very similar to.on
, except that it gives you an array with each update.
Usage
First, import the AgGunModule
with options to your AppModule
:
import { AgGunModule } from 'ag-gun';
@NgModule({
imports: [
AgGunModule.forRoot({
peers: ['https://localhost:8080/gun']
})
]
})
export class AppModule { }
After adding AgGun
service to your component:
import { Component } from '@angular/core';
import { AgGun } from 'ag-gun';
import { Observable } from 'rxjs';
@Component({
selector : 'app-root',
templateUrl: './app.component.html',
styleUrls : ['./app.component.scss']
})
export class AppComponent
{
items$: Observable<any[]>;
constructor(private agGun: AgGun)
{
this.items$ = this.agGun.get('schema').list();
}
}