UNPKG

922 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var once = require("lodash/once");
4var factory_1 = require("./factory");
5var applicators_1 = require("./applicators");
6/**
7 * Creates a function that is restricted to invoking func once. Repeat calls to the function return the value of the first invocation.
8 * This is shared across all instances of the class.
9 * @example
10 * const value = 0;
11 *
12 * class MyClass {
13 * @Once()
14 * fn(): number {
15 * return ++value;
16 * }
17 * }
18 *
19 * const myClass = new MyClass();
20 * const myClass2 = new MyClass();
21 *
22 * myClass.fn(); //=> 1
23 * myClass2.fn(); //=> 1
24 */
25exports.OnceAll = factory_1.DecoratorFactory.createDecorator(new factory_1.DecoratorConfig(once, new applicators_1.PreValueApplicator(), { setter: true, optionalParams: true }));
26exports.onceAll = exports.OnceAll;
27exports.default = exports.OnceAll;
28//# sourceMappingURL=onceAll.js.map
\No newline at end of file