[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?