Weird behaviour when passing function to custom component


Using the following Playground example:

I have a custom component components/comp to which I pass a “parameter” myFunc from the main layout.

Then in comp.js, in the loaded function inside a timeout I call it and it works.

Now, my questions are:

  1. Why does my function call works only if I defer the call using a setTimeout ?
  2. Why if I uncomment the code in comp.js that sets the .contextBinding it changes the value of args.object.myFunc, and my code will stop working as now myFunct is an object not a function anymore ?


That sounds very straight forward, your bindingContext is assigned once the page is loaded, but StackLayout (your custom component) is created even before that.


Pfff… You’re right… Why the hack when I tried this on my machine the order was reversed ? Thank you!

So now it remains only the second question :slight_smile: