[F/OS] - Dynamic Components Extension (for every component) 2.3.0

Example :

It can be used to set the property or invoke the component function of the components we have made using Dynamic component.

7 Likes

Lol you made before me but still example is example lol.

3 Likes

It can do both jobs of GetProperty and SetProperty blocks. Even this block can call all the method and events blocks of the component that you can not do with only SetProperty blocks.

Same here

6 Likes

Yeah :sweat_smile:

Also, there are some improvements in a pull request by @Xoma .

3 Likes

Well in most cases when I donā€™t use schema, I use set properties and dictionary blocks so Iā€™m not familiar with that block. I will try to use it in order to understand better

4 Likes

I had also addressed a bug in Dynamic Components:

2 Likes

Iā€™ve only worked with DC a few times before (something simple with labels or buttons). So Iā€™m not very familiar with it. Since I couldnā€™t find anything about this block either in the AI2 forum or here, there seems to be hardly anyone who has used this block before.

Thanks to all for the helpful hints on how this block works and for unveiling the secret (at least for me) surrounding this block. :wink:

5 Likes

And many thanks to @dora_paz, who is tirelessly busy on both forums (AI2 and here) and giving me some deeper insights into the DC extension (via PM).

4 Likes

Thanks for explanation!

Looks like it is already explained, but I will explain it anyway :grin: In simple terms, it is used to call a componentā€™s function by using its name. It may be sometimes useful because in AI2, you define which method to call or which property to set/get before building the application. You canā€™t call a method dynamically in runtime.

Another example:

However, I donā€™t always recommend using ā€œInvokeā€ instead of componentā€™s own methods because Invoke block only supports basic types (int, string, boolean etc.) of parameters.

Youā€™re right, even including the above example, there is no actually perfect scenario that this block would be useful, I actually added this block for my own use, but is not needed for me either anymore. :joy:

I merged the PR, here is the new build that includes your minor fixes if someone is interested. However, I donā€™t currently plan to announce as a separate version right now (the version name is 2.2.3 anyway), as it just contains few minor additions/fixes.

com.yusufcihan.DynamicComponents.aix (30.1 KB)

8 Likes

Thank you for the explanation!

2 Likes

Also In Thread Property, why there is UI and Main ? Arenā€™t main thread and UI thread are same? I guess one of the value name should be Async, or am i missing something?

1 Like

@oseamiya see ā€¦

1 Like

I mean the terms UI thread and Main thread are same.

4 Likes

Iā€™m sure you got this question from @Xoma, so hereā€™s your answerā€¦

The property chooser has UI and Main as options because their references in Android documentation are alike. Theyā€™re also shown in the code itself (ex: runOnUiThread).

TL;DR: Theyā€™re self-explanatory.

1 Like

runOnUiThread refers to the main app thread. They are basically the same.

This is from Android blog:

3 Likes

Iā€™d always a doubt whenever i have used DynamicComponents extension. I have known that Xoma has presented same question in his PR but I didnā€™t know it has been answered by you already.

Btw, I donā€™t get it. Why there is UI and Main thread in property chooser if they are same?

As far as I know, Activitiyā€™s runOnUiThread execute the Runnable code in the Main/UI thread.


Edit : Thankyou for explaining hammerhai at #1937 ā€¦

3 Likes

The problem is @oseamiya and @Xoma, that they might both be the same threads in the way they work, but they arenā€™t the same.

Turns out, UI and Main threads are not necessarily the same.

Dynamic Components isnā€™t misleading developers by having ā€œtwo of the same thing, but differently named,ā€ theyā€™re just different. Developers at Google wouldnā€™t include a useless runOnUiThread for no reason, as from your standpoint, everything should already be running thereā€¦ right?

F.Y.I @Xoma, in response to your pull request ā€œThey are basically the same, instead, it should be ā€˜Mainā€™ and ā€˜Async.ā€™ā€ They arenā€™t and wonā€™t ever beā€¦ not that Iā€™m stopping you from submitting that change to your heartā€™s desire. Thereā€™s no such thing as ā€œAsync Threadā€ in Android.

1 Like

The thing is UI and Main may not be the same (by exact meanings).

Generally speaking, ā€œa new threadā€.

3 Likes

Thankyou for the explanation !

2 Likes

Good day. Iā€™m trying to create dynamically LineString inside Map.

blocks(3)

But, it shows this error:

Š”Š½ŠøŠ¼Š¾Šŗ эŠŗрŠ°Š½Š° Š¾Ń‚ 2022-02-21 17-52-43

Is it possible to create components dynamically in Map?