How to use the @swim/structure.Attr.of function in @swim/structure

To help you get started, we’ve selected a few @swim/structure 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 swimos / swim / swim-js / swim-core-js / @swim / client / main / downlink / ListDownlinkModel.ts View on Github external
this.listWillRemove(start);
      const oldEntry = this._state.getEntry(start)!;
      deleted.push(oldEntry[1]);
      this._state.remove(start);
      this.listDidRemove(start, oldEntry[1]);
      const header = Record.create(2).slot("key", oldEntry[0]).slot("index", start);
      this.command(Record.create(1).attr("remove", header));
    }
    for (let i = 0; i < newValues.length; i += 1) {
      const index = start + i;
      const newValue = this.listWillUpdate(index, newValues[i]);
      this._state.insert(index, newValue);
      const newEntry = this._state.getEntry(index)!;
      this.listDidUpdate(index, newValue, Value.absent());
      const header = Record.create(2).slot("key", newEntry[0]).slot("index", index);
      this.command(Attr.of("update", header).concat(newValue));
    }
    return deleted;
  }
github swimos / swim / swim-js / swim-core-js / @swim / client / main / downlink / ListDownlinkModel.ts View on Github external
insert(index: number, newValue: Value, key?: Value): this {
    if (index < 0 || index > this._state.length) {
      throw new RangeError("" + index);
    }
    newValue = this.listWillUpdate(index, newValue);
    this._state.insert(index, newValue, key);
    const newEntry = this._state.getEntry(index)!;
    this.listDidUpdate(index, newValue, Value.absent());
    const header = Record.create(2).slot("key", newEntry[0]).slot("index", index);
    this.command(Attr.of("update", header).concat(newValue));
    return this;
  }
github swimos / swim / swim-js / swim-core-js / @swim / client / main / downlink / ListDownlinkModel.ts View on Github external
push(...newValues: Value[]): number {
    for (let i = 0; i < newValues.length; i += 1) {
      const index = this._state.length + i;
      const newValue = this.listWillUpdate(index, newValues[i]);
      this._state.insert(index, newValue);
      const newEntry = this._state.getEntry(index)!;
      this.listDidUpdate(index, newValue, Value.absent());
      const header = Record.create(2).slot("key", newEntry[0]).slot("index", index);
      this.command(Attr.of("update", header).concat(newValue));
    }
    return this._state.length;
  }
github swimos / swim / swim-js / swim-core-js / @swim / client / main / downlink / ListDownlinkModel.ts View on Github external
unshift(...newValues: Value[]): number {
    for (let i = newValues.length - 1; i >= 0; i -= 1) {
      const newValue = this.listWillUpdate(0, newValues[i]);
      this._state.insert(0, newValue);
      const newEntry = this._state.getEntry(0)!;
      this.listDidUpdate(0, newValue, Value.absent());
      const header = Record.create(2).slot("key", newEntry[0]).slot("index", 0);
      this.command(Attr.of("update", header).concat(newValue));
    }
    return this._state.length;
  }
github swimos / swim / swim-js / swim-core-js / @swim / client / main / downlink / ListDownlinkModel.ts View on Github external
set(index: number, newValue: Value, key?: Value): this {
    if (key !== void 0) {
      index = this._state.lookup(key, index);
      if (index < 0) {
        throw new RangeError("" + key);
      }
    }
    if (index < 0 || index >= this._state.length) {
      throw new RangeError("" + index);
    }
    newValue = this.listWillUpdate(index, newValue);
    const oldEntry = this._state.getEntry(index)!;
    this._state.set(index, newValue);
    this.listDidUpdate(index, newValue, oldEntry[1]);
    const header = Record.create(2).slot("key", oldEntry[0]).slot("index", index);
    this.command(Attr.of("update", header).concat(newValue));
    return this;
  }