Search Callback System- App Dev Series 12

Objective: create a search callback system to make method can check the result automatically.

Photo by Javier Esteban on Unsplash

We have called a method to process the function to lookup files in server, and how do we know the searching is finished?
In this article, we will create a callback system to do this part to make our app proceed.

Action, as parameter

As we calling a method to run the process, we can use Action as one of the parameter.
In this Action parameter, create a method name and we can call it with some condition.

We have create a method parameter called onComplete.

Then using this parameter method when the progress of this whole method is about reaching the end.

In here I have created a null check to prevent the onComplete() runs under no parameter.

Pass in the parameter with Lambda

Back to where we called this method, using Lambda Expressions to make onComplere() works.

When GetList is finished running and reached the last line of code, it would callback and run this line: selectPanel.gameObject.SetActive(true).

That is how we got a functional callback system.

A passionate gamer whose goal is to work in video game development.