0.0.6 • Published 5 years ago

ag-gun v0.0.6

Weekly downloads
6
License
MIT
Repository
github
Last release
5 years ago

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();
  }
}
0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago