Psst.. new poll here.
[email protected] webmail now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!
Paste
Pasted as JavaScript by x ( 6 years ago )
let fooServiceInstance = null;
export default class FooService {
constructor() {
if (fooServiceInstance) {
return fooServiceInstance;
}
fooServiceInstance = this;
}
loadFoo() {
return fetch();
}
getFoo(forceReload) {
if (this.foo && !forceReload) {
return Promise.resolve(this.foo);
}
return this.loadFoo()
.then(foo => this.foo = foo)
.then(() => this.foo);
}
}
import S from './s';
const s1 = new S();
const s2 = new S();
s1.getFoo().then(() => s2.getFoo())
Revise this Paste