How to use the @glimmer/component.UpdatableReference function in @glimmer/component

To help you get started, we’ve selected a few @glimmer/component 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 bakerac4 / glimmer-native / src / glimmer / helpers / action.ts View on Github external
export default function(_args, vm) {
    // console.log(`in action`);
    let componentRef = vm.getSelf();
    // console.log(`componentRef: ${componentRef}`);
    let args = _args.capture();

    let actionFunc = args.positional.at(0).value() as Function;
    // console.log(actionFunc);
    // if (typeof actionFunc !== 'function') {
    //   throwNoActionError(actionFunc, args.positional.at(0));
    // }

    return new UpdatableReference(function action(...invokedArgs) {
        //   console.log(`in updatable reference`);
        let curriedArgs = args.positional.value();
        //   console.log(`in updatable reference: ${curriedArgs}`);
        // Consume the action function that was already captured above.
        curriedArgs.shift();

        curriedArgs.push(...invokedArgs);

        // Invoke the function with the component as the context, the curried
        // arguments passed to `{{action}}`, and the arguments the bound function
        // was invoked with.
        actionFunc.apply(componentRef && componentRef.value(), curriedArgs);
    });
}
github bakerac4 / glimmer-native / dist / src / glimmer / helpers / action.js View on Github external
export default function (_args, vm) {
    // console.log(`in action`);
    let componentRef = vm.getSelf();
    // console.log(`componentRef: ${componentRef}`);
    let args = _args.capture();
    let actionFunc = args.positional.at(0).value();
    // console.log(actionFunc);
    // if (typeof actionFunc !== 'function') {
    //   throwNoActionError(actionFunc, args.positional.at(0));
    // }
    return new UpdatableReference(function action(...invokedArgs) {
        //   console.log(`in updatable reference`);
        let curriedArgs = args.positional.value();
        //   console.log(`in updatable reference: ${curriedArgs}`);
        // Consume the action function that was already captured above.
        curriedArgs.shift();
        curriedArgs.push(...invokedArgs);
        // Invoke the function with the component as the context, the curried
        // arguments passed to `{{action}}`, and the arguments the bound function
        // was invoked with.
        actionFunc.apply(componentRef && componentRef.value(), curriedArgs);
    });
}

@glimmer/component

Glimmer component library

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis