Trending
Nigeria: Gombe PDP Politicising Diphtheria Outbreak - APC is trending now Zamfara Records 367 Confirmed Diphtheria Cases, 320 Recover is trending now Africa accounts for 75% of global Mpox cases in July- WHO is trending now Quantum entanglement confirmed in Z bosons at Large Hadron Collider is trending now Rust prevention coating uses nanotech to self-repair and conquer corrosion is trending now 'If I wanted to go to space, I would have stayed at NASA': What's next for Artemis II ast… is trending now After the refereeing case in the Manchester derby, Rooney snaps: "Enough with VAR, it's h… is trending now Spurs' Richarlison posts 'Why?' and a tearful emoji after he is left out of Liverpool Car… is trending now 'Truly incredible!' - Alvaro Morata backs Lamine Yamal for Ballon d'Or glory after witnes… is trending now London misses out to Nairobi in World Athletics bid is trending now BBNaija S11: Abi, Araga Evicted In Week Seven is trending now Peller quickly retraces his steps after comparing Ochacho’s son’s streams to Champz’s num… is trending now Nigeria: Gombe PDP Politicising Diphtheria Outbreak - APC is trending now Zamfara Records 367 Confirmed Diphtheria Cases, 320 Recover is trending now Africa accounts for 75% of global Mpox cases in July- WHO is trending now Quantum entanglement confirmed in Z bosons at Large Hadron Collider is trending now Rust prevention coating uses nanotech to self-repair and conquer corrosion is trending now 'If I wanted to go to space, I would have stayed at NASA': What's next for Artemis II ast… is trending now After the refereeing case in the Manchester derby, Rooney snaps: "Enough with VAR, it's h… is trending now Spurs' Richarlison posts 'Why?' and a tearful emoji after he is left out of Liverpool Car… is trending now 'Truly incredible!' - Alvaro Morata backs Lamine Yamal for Ballon d'Or glory after witnes… is trending now London misses out to Nairobi in World Athletics bid is trending now BBNaija S11: Abi, Araga Evicted In Week Seven is trending now Peller quickly retraces his steps after comparing Ochacho’s son’s streams to Champz’s num… is trending now
XML

Building a Task Sequence in Xamarin Forms/ MAUI (Part 2)

Building a Task Sequence in Xamarin Forms/ MAUI (Part 2)

In the first part of this series, we covered how to build a task sequence. In this part I’m going to show you how to… Continue ReadingBuilding a Task Sequence in Xamarin Forms/ MAUI (Part 2) The post Building a Task Sequence in Xamarin Forms/ MAUI (Part 2) appeared first on Xamboy.

In the first part of this series, we covered how to build a task sequence. In this part I’m going to show you how to start the sequence from a specific task, run tasks conditionally and pass parameters between tasks.

Starting from an specific task

There are scenarios where we want the task sequence to start from a task. For example, you want to start in the HomePage and skip all the previous tasks.

To achieve it, create an overload for StartAsync method of the StartupTaskSequencer class that will take an IStartupTask as parameter. This task will be the starting task in the sequence, so all the tasks previous to this one will be skipped.

In the SplashPage, when calling the StartAsync method specify which task we want to start from.

Result:

Run tasks conditionally

Is very common to run tasks only if it meets certain conditions. For example, if you have an application that shows an advertisement task only if the user is using the free version otherwise this task should be skipped.

To represent this scenario, let’s add a property for the version type in the App class.

In the AdvertisingPage by overriding the CanRunAsync method, evaluate if VersionType is free. If so task should run, otherwise will be skipped.

Passing parameters

In certain use cases we might need the output of the previous task to be the input of the next task to run. For example, you want to pass the username from the LoginPage task to the HomePage task.

To achieve it, let’s create a class to represent parameters:

Modify the IStartupTask to support parameters:

Modify StartupTaskSequencer class to pass parameters of previous task to the next running task

Pass the parameters in the CompleteAsync method of the previous task:

Evaluate and consume the parameters in the next task.

Result:

Stay tuned for the next part of this series where you’ll see how to build a task sequence using Prism.

Check the full source code here.

Happy Task Sequence!

The post Building a Task Sequence in Xamarin Forms/ MAUI (Part 2) appeared first on Xamboy.

View original source →

Related