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.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Code Review at Frontline

How Defining Code Owners Can Radically Improve Your Code Reviews

Ad-hoc Tools for Sharing Jupyter Notebooks in AWS SageMaker

Synapse TechSpecs: Custom Handler

Decoding Picasso library- one image at a time.


Jetpack MVI Best Practice

LGM-SOC Experience as a Mentor

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
S.J. Jason Liu

S.J. Jason Liu

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

More from Medium

2D Mobile: Designing Enemies Using Abstract Classes

Building A Stealth Game — Helping Your Guards “See”

Day 106: Create a Roll system.

Optimizing Unity Workflow Using Layouts