MobileApp Block custom method

MobileApp Block custom method

  

Hi everyone!


Is it possible to create "methods" for a block, for instance, a SetVisible(true/false) method to change the block content visibility ?


How can I archive that ?


Thanks in advance.


Hi Luciano,

Not sure if I understood it correctly but, why not a container wrapping the block with the condition on the visible?

Otherwise you can have a boolean input parameter that controls an If that has all the content inside.

Let me know if it worked.

Cheers,

Hi Henrique, thank you for the response.

Actually, I want to build a reusable block with more complex methods that "SetVisible". That was just an example to try to clarify my needs.

I understand you suggestion works fine, but I really need a block with methods, not only input parameters and events. That way I can create better reusable components.

Do you know how I can do this ?


I'm not really getting what do you want to achieve, can you give me a couple of examples? Because if it's reusable logic, usually goes to the 'global' actions.

The only way that I see to achieve it with block is the following:

Static entity {Action A, Action B} - To define which logic will run

The block as an input parameter of StaticEntityId, and an event of OnParametersChange, and on the action that handles the event, you have a an If/Switch that will redirect to the correct action needed.

Do you think that will work?

Solution

Hi Luciano,

You should use block parameters to immediately react to screen changes. Despite this, if you really need to programatically call block actions from the screen you can actually define a proper API for your block and call it from your screen. Consider following this documentation:

https://success.outsystems.com/Documentation/Development_FAQs/How_to_Call_a_Block_Action_in_a_Mobile_Screen


Cheers,

Vasco Pessanha

Solution

Hi guys!

I think the solution Vasco suggested is what I need. I'll give a try on it and let you know the result.

Henrique, I really appreciate your hel too... thank you and Vasco very much!

Cheers

Sure, actually I didn't know that also and it enables a whole new set of possibilities.

Always learning :)