Home Reference Source
import {CoreBase} from '@osjs/common/src/core.js'
public class | source

CoreBase

Extends:

@osjs/event-emitter~EventEmitter → CoreBase

Main class for OS.js service providers and bootstrapping.

Constructor Summary

Public Constructor
public

constructor(defaultConfiguration: Object, configuration: Object, options: Object)

Create core instance

Method Summary

Public Methods
public

boot(): *

Boots up OS.js

public

config(key: String, defaultValue: *): *

Gets a configuration entry by key

public

destroy(): *

Destroy core instance

public

has(name: String): Boolean

Check if a service exists

public

instance(name: String, callback: Function)

Register a instanciator provider

public

make(name: String, args: *): *

Create an instance of a provided service

public

register(ref: Class, options: Object)

Register a service provider

public

singleton(name: String, callback: Function)

Register a singleton provider

public

start(): *

Starts all core services

Public Constructors

public constructor(defaultConfiguration: Object, configuration: Object, options: Object) source

Create core instance

Params:

NameTypeAttributeDescription
defaultConfiguration Object

Default configuration

configuration Object

Configuration given

options Object

Options

Public Methods

public boot(): * source

Boots up OS.js

Return:

*

public config(key: String, defaultValue: *): * source

Gets a configuration entry by key

Params:

NameTypeAttributeDescription
key String

The key to get the value from

defaultValue *
  • optional

If result is undefined, return this instead

Return:

*

See:

public destroy(): * source

Destroy core instance

Return:

*

public has(name: String): Boolean source

Check if a service exists

Params:

NameTypeAttributeDescription
name String

Provider name

Return:

Boolean

public instance(name: String, callback: Function) source

Register a instanciator provider

Params:

NameTypeAttributeDescription
name String

Provider name

callback Function

Callback that returns an instance

public make(name: String, args: *): * source

Create an instance of a provided service

Params:

NameTypeAttributeDescription
name String

Service name

args *

Constructor arguments

Return:

*

An instance of a service

public register(ref: Class, options: Object) source

Register a service provider

Params:

NameTypeAttributeDescription
ref Class

A class reference

options Object
  • optional

Options for handling of provider

options.before Boolean
  • optional

Load this provider early

options.args Object
  • optional

Arguments to send to the constructor

public singleton(name: String, callback: Function) source

Register a singleton provider

Params:

NameTypeAttributeDescription
name String

Provider name

callback Function

Callback that returns an instance

public start(): * source

Starts all core services

Return:

*