EdwardZZZ / articles

工作点滴记录
2 stars 0 forks source link

RPC invoke #79

Closed EdwardZZZ closed 3 years ago

EdwardZZZ commented 3 years ago
// generic code
class DynaicContext {
    constructor({
        publicParasm,
        params,
        headerMap,
    }) {
        this.publicParasm = publicParasm;
        this.params = params;
        this.headerMap = headerMap;
    }

    publicParasm;
    params;
    headerMap;
}

function RPCProxy() {}

class BaseService {
    invoke(...props: any[]) {
        return RPCProxy();
    }
}

class HSF extends BaseService {
    getDynaicData(dynaicContext: DynaicContext) {
        return RPCProxy();
    }
}

// code
const hsf = new HSF();

hsf.getDynaicData(new DynaicContext({
    publicParasm: {},
    params: {},
    headerMap: new Map(),
}));

hsf.invoke('getDynaicData', new DynaicContext({
    publicParasm: {},
    params: {},
    headerMap: new Map(),
}));