### File

`projects/app-base-library/src/lib/shared/base.ts`

### Index

###### Properties

- Private _environment
- Private _settings
- Public settings

###### Methods

- Protected init

### Constructor

`constructor()`
Defined in projects/app-base-library/src/lib/shared/base.ts:10

### Properties

Private _environment
`_environment: `any``
Type : `any`
Default value : `{ type: 'js', namespace: '_abl'}`
Defined in projects/app-base-library/src/lib/shared/base.ts:8

Private _settings
`_settings: `any``
Type : `any`
Default value : `{}`
Defined in projects/app-base-library/src/lib/shared/base.ts:9

Public settings
`settings: `any``
Type : `any`
Default value : `{}`
Defined in projects/app-base-library/src/lib/shared/base.ts:10

### Methods

Protected init
`init(settings: any)`
Defined in projects/app-base-library/src/lib/shared/base.ts:35

Parameters :

Name | Type | Optional
settings | `any` | no

Returns : `any`

    declare var Promise;
    declare var fetch;

    export class Base {
        /*
        * Application base class: initializes global '_abl' namespace
        * */
        private _environment: any = { type: 'js', namespace: '_abl'};
        private _settings: any = {};
        public settings: any = {};

        constructor() {
            // browser
            if (typeof window !== 'undefined') {
                this._environment.type = 'browser';
                if (window['angular']) {
                    this._environment.framework = 'angular-js';
                }
                if (!window['angular']) {
                    this._environment.framework = 'angular';
                }
                if (!window[this._environment.namespace]) {
                    (<any>window)[this._environment.namespace] = {};
                }
            }
            // nodejs
            if (typeof window === 'undefined') {
                this._environment.type = 'nodejs';
                this._environment.framework = 'nodejs';
            }
            this._environment.date = new Date();
            this._environment.started = Math.round(+new Date() / 1000);
        }

        protected init(settings: any) {
            const self = this;
            return new Promise(function(resolve, reject) {
                if (typeof settings === 'string') {
                    fetch(settings)
                        .then(function(response) {
                            return response.json();
                        })
                        .then(function(json) {
                            self.settings = json;
                            resolve();
                        });
                } else {
                    self.settings = settings;
                    resolve();
                }
            });
        }

        // todo: load namespace library
        // loadLibrary(paths){
        //     let self = this;
        //     let classes = [];
        //     _.each(paths,function(oath){
        //         classes.push(self.classRef());
        //     });
        //     console.log(classes);
        // }
        //
        // classRef(path:string){
        //     _.each(this._namespace,function(ns){
        //         _.each(ns,function(v,k){
        //             console.log(k+' = '+v);
        //             if(k==path){
        //                 return v;
        //             }
        //         });
        //     });
        // }
        //
        // set classPath(path:string){
        //     let atPath = '';
        //     let parts = path.split('.');
        //     if(this._namespace[path]){
        //         console.error('classPath: '+path+'is already defined.');
        //         return;
        //     }
        //     _.each(parts,function(p){
        //         atPath += p+'.'
        //     });
        //     console.log(atPath);
        //    // this._namespace[path]=
        //
        // }

    }

# results matching ""

# No results matching ""