fix(search): show torrent page from remote peer
This commit is contained in:
29
src/app/singleton.js
Normal file
29
src/app/singleton.js
Normal file
@ -0,0 +1,29 @@
|
||||
export default (Superclass) => {
|
||||
let instance;
|
||||
|
||||
return class Singleton extends Superclass {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
if (instance) {
|
||||
instance.props = props
|
||||
return instance;
|
||||
}
|
||||
instance = this;
|
||||
}
|
||||
static instance() {
|
||||
if (instance) {
|
||||
return instance;
|
||||
} else {
|
||||
return new Singleton();
|
||||
}
|
||||
}
|
||||
static do(key, ...params) {
|
||||
if ( typeof this.instance()[key] === 'function') {
|
||||
return this.instance()[key](...params);
|
||||
} else {
|
||||
return this.instance()[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user