// import { ajax } from 'rxjs/ajax';
import { Observable } from 'rxjs/internal/Observable';
import { Http } from '../../http/http';
const singleton = Symbol();
const singletonEnforcer = Symbol();
export class HttpService extends Http {
    constructor(enforcer) {
        super();
        if (enforcer !== singletonEnforcer) {
            throw new Error('Cannot construct singleton');
        }
        this._type = 'HttpService';
    }
    get(url, options = {}) {
        let preflight = this.preflightGet(url, options);
        return Observable.create(observer => {
            fetch(preflight.url, preflight.options)
                .then(response => response.json()) // or text() or blob() etc.
                .then(data => {
                observer.next(data);
                observer.complete();
            })
                .catch(err => {
                console.error(err);
                observer.error(err);
            });
        });
    }
    put(url, object, options) {
    }
    post(url, object, options) {
    }
    delete(url, object, options) {
    }
    static get instance() {
        if (!this[singleton]) {
            this[singleton] = new HttpService(singletonEnforcer);
        }
        return this[singleton];
    }
    get type() {
        return this._type;
    }
    set type(value) {
        this._type = value;
    }
}
//# sourceMappingURL=http-service.js.map