Skip to content

Commit 88acd22

Browse files
committed
[poid] added a proxy for gs scheme
SQUASHED: AUTO-COMMIT-src-client-poid.js,
1 parent 68aeb15 commit 88acd22

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/client/poid.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,42 @@ export class Lively4URLScheme extends Scheme {
844844
}
845845
}
846846

847+
export class GSScheme_Stub extends Scheme {
848+
849+
get scheme() {
850+
return "gs";
851+
}
852+
853+
resolve() {
854+
return true
855+
}
856+
857+
static async delegatee() {
858+
if (this._delegatee) {
859+
return this._delegatee;
860+
} else {
861+
return this._delegateePromise = this._delegateePromise || new Promise(resolve => this._delegateeResolve = resolve);
862+
}
863+
}
864+
865+
static delegateTo(Scheme) {
866+
this._delegatee = Scheme;
867+
this._delegateeResolve && this._delegateeResolve(this._delegatee);
868+
}
869+
870+
async holdOff(methodName, ...args) {
871+
const NewScheme = await GSScheme_Stub.delegatee();
872+
this.migrateTo(NewScheme);
873+
return this[methodName](...args);
874+
}
875+
876+
async GET(...args) { return this.holdOff('GET', ...args); }
877+
async PUT(...args) { return this.holdOff('PUT', ...args); }
878+
async OPTIONS(...args) { return this.holdOff('OPTIONS', ...args); }
879+
async POST(...args) { return this.holdOff('POST', ...args); }
880+
async DELETE(...args) { return this.holdOff('DELETE', ...args); }
881+
}
882+
847883

848884
export default class PolymorphicIdentifier {
849885

@@ -868,6 +904,7 @@ export default class PolymorphicIdentifier {
868904
DateScheme,
869905
BooleanScheme,
870906
Lively4URLScheme,
907+
GSScheme_Stub,
871908
].forEach(scheme => this.register(scheme));
872909
}
873910

0 commit comments

Comments
 (0)