How to use the @effectful/serialization.regConstructor function in @effectful/serialization

To help you get started, we’ve selected a few @effectful/serialization examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github awto / effectfuljs / packages / debugger / src / timeTravel / main.ts View on Github external
Object.defineProperty(this, propName, {
        configurable: true,
        set(value) {
          Core.record(new PropSnapshot(this, propName, this[sym], value));
          this[sym] = value;
        },
        get() {
          return this[sym];
        }
      });
    },
    get() {}
  });
}

if (config.persistTimeTravel) S.regConstructor(Core.TraceData);
else S.regConstructor(Core.TraceData, S.NotSerializableDescriptor);
github awto / effectfuljs / packages / debugger / src / timeTravel / main.ts View on Github external
};

PropSnapshot.prototype.call = config.timeTravelForward
  ? function(this: IPropSnapshot) {
      if (this.back) {
        if (this.oldValue === deleteTag) delete this.target[this.index];
        else this.target[this.index] = this.oldValue;
      } else this.target[this.index] = this.newValue;
      this.back = !this.back;
      Core.record(this);
    }
  : function(this: IPropSnapshot) {
      if (this.oldValue === deleteTag) delete this.target[this.index];
      else this.target[this.index] = this.oldValue;
    };
S.regConstructor(PropSnapshot);

/**
 * defines setter a getter in `value` to support time travel
 * TODO: delete handler
 */
export function propHack(value: any, propName: string) {
  const sym = Symbol(`${propName}`);
  Object.defineProperty(value, propName, {
    set(value) {
      this[sym] = value;
      Core.record(new PropSnapshot(this, propName, deleteTag, value));
      Object.defineProperty(this, propName, {
        configurable: true,
        set(value) {
          Core.record(new PropSnapshot(this, propName, this[sym], value));
          this[sym] = value;
github awto / effectfuljs / packages / es-persist-serialization / main.js View on Github external
R.constructors.forEach(v => S.regConstructor(v));
export const asyncFunction = R.makeAsyncFunctionConstructor(S.regConstructor);