We are trying to be consistent with all Baasic JavaScript based SDKs, and Angular SDK is no different. It follows the one-service-per-module practice, so developers can easily find and access Baasic REST API end-points. Library uses all JavaScript SDK built-in handlers, except HttpClient Handler, which is built on top of Angular Http service. As always, to make our SDKs better, we would like to hear from you, so download the latest version from GitHub or npm, and let us know what you think.

Architecture

With this release, we moved away from Gulp to even more popular WebPack bundler, while keeping all Baasic modules inside one Git repository. Angular SDK automatically handles Baasic token storage and similar features.

Since Angular SDK depends on Baasic JavaScript SDK, which is built using TypeScript, it gives us a strongly-typed way of using Angular SDK. Using TypeScript, the inheritance of any Baasic model can be extended - all you need to do is add your properties and save the model using Angular service.

What’s included in the RC version

  • Modules
    • Core communication
    • Membership & Security
    • Key Value & Value Set module
    • Dynamic Resource module
    • Article module
    • Profile module
    • Notification module
    • Templating module
    • Metering module
    • Media Vault & Files module

Setup

To properly configure your solution for using Angular SDK, you will need to add the following line to your package.config file:

"baasic-sdk-angular": "1.0.0-RC.1",

Initialization

To be able to use the library, add Baasic (BaasicApp) dependency to your Angular module:

import { BaasicApp } from 'baasic-sdk-angular';

Application Configuration

Baasic Angular SDK library allows you to use a single Baasic application in your Angular modules. To initialize an application, add the following code to your module configuration:

@NgModule({
  ...,
  imports: [ 
    ...,
    BaasicApp.forRoot('<api-key>', {
            apiRootUrl: "api.baasic.com",
            apiVersion: "<version>"      
    })
  ],
  ...
})

Usage

In order to use any of the Baasic Angular SDK services, you need to inject them into your service as follows:

import { Injectable } from '@angular/core';
import {
    MembershipService,
    IOptions,
    IHttpResponse,
    IBaasicQueryModel,
    IRole
} from 'baasic-sdk-angular';

@Injectable()
export class RoleService {

    constructor(private membershipService: MembershipService) { }

    async getAll(): Promise<IBaasicQueryModel<IRole>> {
        var result = await this.membershipService.role.find();

        return Promise.resolve(result.data);
    }
}

Note: To obtain the Baasic Application Identifier, please create your application through the Baasic Registration page.

To get more information about the configuration, please visit Baasic Developer Center or baasic-sdk-angular GitHub repository.

Coming soon

We are moving forward with Angular SDK (v2+) documentation, which will provide detailed information about the SDK structure, classes, and models, and will be available soon in the Baasic Developer Center.

One of the next things on our roadmap are React examples to jump-start React development.

We have already started working on Node.js SDK, and although it is in alpha version, we tested it in an IoT project which connects the BMW car to Raspberry PI. The project is available on our demo site Baasic ShowCase IoT RaspberryPI BMW and GitHub, so stay tuned.

Feel free to leave a comment

comments powered by Disqus