How to use the core-decorators.autobind function in core-decorators

To help you get started, we’ve selected a few core-decorators 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 Azure / BatchExplorer / app / components / file / details / file-details.component.ts View on Github external
this.jobId = params["jobId"];
            this.taskId = params["taskId"];
            this.poolId = params["poolId"];
            this.nodeId = params["nodeId"];
            this.outputKind = params["outputKind"];
            this.filename = params["filename"];

            this._loadFileProperties();
        }));
    }

    public ngOnDestroy() {
        this._paramsSubscribers.forEach(x => x.unsubscribe());
    }

    @autobind()
    public refresh() {
        return Observable.of({});
    }

    @autobind()
    public downloadFile() {
        const dialog = remote.dialog;
        const localPath = dialog.showSaveDialog({
            buttonLabel: "Download",
            // Set default filename of file to download
            defaultPath: FileUrlUtils.getFileName(this.url),
        });

        if (localPath) {
            return this._saveFile(localPath);
        }
github Azure / BatchExplorer / app / components / file / browse / node-file-list.component.ts View on Github external
constructor(private fileService: FileService) { }

    public ngOnChanges(inputs) {
        if (inputs.poolId || inputs.nodeId || inputs.folder || inputs.filter) {
            this._initProxyMap(inputs);
            this.refresh();
        }
    }

    public ngOnDestroy(): void {
        this.status.unsubscribe();
        this.error.unsubscribe();
    }

    @autobind()
    public refresh(): Observable {
        if (this.poolId && this.nodeId) {
            // filter is changed in two different situation (search field of node file list and file nav list)
            const filterProp = ((this.filter.properties && this.filter.properties.length > 0) ?
                                        this.filter.properties[0] : this.filter) as Property;
            const quickSearch = filterProp && filterProp.value;
            const loadPath = [this.folder, quickSearch].filter(x => Boolean(x)).join("/");
            if (this.treeDisplay) {
                return this.treeDisplay.initNodes(loadPath, true);
            }
        }
        return Observable.of(true);
    }

    public get baseUrl() {
        return ["/pools", this.poolId, "nodes", this.nodeId];
github RoboPhred / oni-duplicity / src / pages / SaveEditor / components / fields / BooleanField.tsx View on Github external
} from "./connect-field";

import Input from "@/components/Input";

export interface BooleanFieldProps extends EditorFieldProps {}

type Props = BooleanFieldProps & InjectedProps;
class BooleanField extends React.Component {
  render() {
    const { value } = this.props;
    return (
      <input value="{value}" type="checkbox">
    );
  }

  @autobind()
  private _onValueChange(e: React.ChangeEvent) {
    const value = e.target.checked;
    const { onCommit } = this.props;
    onCommit(value);
  }
}
export default connectEditorField()(BooleanField);
github RoboPhred / oni-duplicity / src / components / TextAutocompleteInput.tsx View on Github external
return (
       x}
        onChange={this._onValueChange}
        onSelect={this._onValueSelect}
        selectOnBlur
      /&gt;
    );
  }

  @autobind()
  private _onValueChange(e: React.ChangeEvent) {
    const value = e.target.value;
    this._setEditValue(value);
  }

  @autobind()
  private _onValueSelect(value: string) {
    this._setEditValue(value, () =&gt; {
      this._commitEdit();
    });
  }

  private _setEditValue(value: string, onSet?: () =&gt; void) {
    const validation = this._validate(value);
    const isValid = !validation;
github RoboPhred / oni-duplicity / src / components / TextInput.tsx View on Github external
return (
      <input value="{currentValue}" maxlength="{maxLength}" minlength="{minLength}" type="text">
    );
  }

  @autobind()
  private _onValueChange(e: React.ChangeEvent) {
    const value = e.target.value;
    this._setEditValue(value);
  }

  @autobind()
  private _onInputKeyPress(e: React.KeyboardEvent) {
    if (e.key === Keys.Enter) {
      this._commitEdit();
    }
  }

  @autobind()
  private _onInputBlur() {
    this._commitEdit();
  }
github RoboPhred / oni-duplicity / src / components / CheckInput.tsx View on Github external
export interface CheckInputProps {
  value: boolean;
  onCommit(value: boolean): void;
}

type Props = CheckInputProps;
export default class CheckInput extends React.Component {
  render() {
    const { value } = this.props;
    return (
      <input checked="{value}" type="checkbox">
    );
  }

  @autobind()
  private _onValueChange(e: React.ChangeEvent) {
    const { onCommit } = this.props;
    const value = e.target.checked;
    onCommit(value);
  }
}
github RoboPhred / oni-duplicity / src / components / NumericInput.tsx View on Github external
return (
      <input step="{step}" value="{currentValue}" max="{maxValue}" min="{minValue}" type="number">
    );
  }

  @autobind()
  private _onValueChange(e: React.ChangeEvent) {
    const { minValue, maxValue } = this.props;
    const editValue = e.target.value;
    const numberValue = parseFloat(editValue);
    let validationMessage: string | null = null;

    if (maxValue != null &amp;&amp; numberValue &gt; maxValue) {
      validationMessage = `Value must be less than ${maxValue}`;
    } else if (minValue != null &amp;&amp; numberValue &lt; minValue) {
      validationMessage = `Value must be greater than ${minValue}`;
    }

    e.target.setCustomValidity(validationMessage || "");

    this.setState({
      editValue,
github Azure / BatchExplorer / app / components / file / browse / persisted-file-list.component.ts View on Github external
});
    }

    public ngOnChanges(inputs) {
        if (inputs.jobId || inputs.taskId || inputs.filter) {
            this.refresh();
        }
    }

    public ngOnDestroy() {
        this.status.unsubscribe();
        this._autoStorageSub.unsubscribe();
        this._statuSub.unsubscribe();
    }

    @autobind()
    public refresh(): Observable {
        if (this.jobId &amp;&amp; this.taskId &amp;&amp; this.outputKind) {
            this._loadFiles();
        }

        return Observable.of(true);
    }

    @autobind()
    public loadMore(): Observable {
        if (this.data &amp;&amp; this.hasAutoStorage) {
            return this.data.fetchNext();
        }

        return new Observable(null);
    }
github Azure / BatchExplorer / app / components / file / browse / task-file-list.component.ts View on Github external
private nodeService: NodeService,
        private taskService: TaskService) { }

    public ngOnChanges(inputs) {
        if (inputs.jobId || inputs.taskId || inputs.filter) {
            this._initProxyMap(inputs);
            this.refresh();
        }
    }

    public ngOnDestroy(): void {
        this.status.unsubscribe();
        this.error.unsubscribe();
    }

    @autobind()
    public refresh(): Observable {
        if (this.jobId &amp;&amp; this.taskId) {
            this._loadIfNodeExists();
        }
        return Observable.of(true);
    }

    public get baseUrl() {
        return ["/jobs", this.jobId, "tasks", this.taskId];
    }

    public get filterPlaceholder() {
        return "Filter by file name";
    }

    @autobind()
github RoboPhred / oni-duplicity / src / components / ActiveAwareLink / component.tsx View on Github external
...other
        } = this.props
        const pathName = location.pathname;
        let match: boolean;
        
        if (exact) match = to === pathName;
        else match = matchPartialPath(pathName, to.toString());

        if (match) {
            return <span>{children}</span>;
        }

        return {children};
    }

    @autobind()
    private _onClick(event: React.MouseEvent) {
        const {
            exact,
            location,
            to,
            onClick
        } = this.props;
        const pathName = location.pathname;

        let match: boolean;
        if (exact) match = to === pathName;
        else match = matchPartialPath(pathName, to.toString());

        if (match) {
            event.preventDefault();
            return;

core-decorators

Library of JavaScript stage-0 decorators (aka ES2016/ES7 decorators but that's not accurate!) inspired by languages that come with built-ins like @​override, @​deprecate, @​autobind, @​mixin and more! Works great with React/Angular/more!

MIT
Latest version published 7 years ago

Package Health Score

56 / 100
Full package analysis

Popular core-decorators functions