Exteranto

The browser extension framework

View the Project on GitHub exteranto/exteranto.github.io

Getting Started
Installation
Directory Structure
Application Configuration

Tutorials
Your First Exteranto

Concepts
Browser Extension Basics
Handling the IOC Container
Typed Message Passing
Service Providers

Service Providers

As in many other frameworks, providers in Exteranto serve as primary means of registering services. These services can be native from Exteranto, third-party services or even those created in the application itself.

Methods

Exteranto provides an abstract class Provider that comes with three methods:

All providers have access to a container class variable that references the current instance of the IOC Container, and a dispatcher class variable containing a reference to the Event Dispatcher.

Here is an example of a healthy service provider:

import { Event } from '...'
import { Service } from '...'
import { Listener } from '...'

import {
  Script,
  Provider,
  Dispatcher,
} from '@exteranto/core'

export class AppProvider extends Provider {
  public only () : Script[] {
    return [Script.BACKGROUND]
  }

  public boot () : void {
    this.container.bind(Service).toSelf()
  }

  public register () : void {
    this.dispatcher.touch(Event)
      .addLisgtener(Listener)
  }
}

Registering the Provider

All providers are registered in the Application Configuration file in the providers array. If using the exteranto skeleton application, the correct place to register a provider is demarcated by a comment.