Detecting end of function chain?

Today I am working on a pet project using whole function calls, and I'm curious how I can detect when the last function in the chain is executed. For instance:

func1('initial data').func2().func3().func4();

And after func2-4 finished working on the "source data", I would like to determine when func4 will be executed. Since func4 () is not always the last function in the chain, for example, it can end with .func3 () or .func5 (), for example, or I could mix function calls depending on what I'm trying to do, I'm trying to come up with way to detect more function calls, but I'm not very far away.

0
source share
3

.

, :

var v = func1('initial data');
v = v.func2();
v = v.func3();
v = v.func4();

? , - , .

, , .

+4

, , :

func1('initial data').func2().func3().func4();
allFunctionsDone();

;)

+4

, . , , . -

executeSequence(func1('init_dat'),[
    'func2',
    'func3',
    'func4'
]);
+3

Source: https://habr.com/ru/post/1733783/


All Articles