0.0.5 • Published 5 years ago

@mailchain/nameservice-angular v0.0.5

Weekly downloads
5
License
Apache-2.0
Repository
github
Last release
5 years ago

NameserviceAngular

This package is an Angular service that helps query the Mailchain API nameservice endpoint.

Installing

npm install @mailchain/nameservice-angular --save

Usage

In your Angular app.module.ts file, import the NameserviceAngularModule:

import { NameserviceAngularModule } from '@mailchain/nameservice-angular';

@NgModule({
  declarations: [
    AppComponent
    ...
  ],
  imports: [
    ...
    NameserviceAngularModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

In an Angular component file, eg. my-component.component.ts, add the following:

  // import the service
  import { NameserviceService } from '@mailchain/nameserver-angular';

  // add to constructor
  constructor(
    private nameserviceService: NameserviceService,
  ) { }

  // add to function and then execute logic in the callback
  myFunction() {
    const protocol = "ethereum" // change accordingly or use function params
    const network = "mainnet" // change accordingly or use function params

    const obs = this.nameserviceService.resolveName(protocol, network, value)

    obs.subscribe(obs => {
      console.log(obs['body']) // Expect: { address: "0x1234....", status: 0}
    })
  }

This library was generated with Angular CLI version 8.2.14.

Code scaffolding

Run ng generate component component-name --project nameservice-angular to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module --project nameservice-angular.

Note: Don't forget to add --project nameservice-angular or else it will be added to the default project in your angular.json file.

Build

Run ng build nameservice-angular to build the project. The build artifacts will be stored in the dist/ directory.

Publishing

After building your library with ng build nameservice-angular, go to the dist folder cd dist/nameservice-angular and run npm publish.

Running unit tests

Run ng test nameservice-angular to execute the unit tests via Karma.

Further help

To get more help on the Angular CLI use ng help or go check out the Angular CLI README.