Show loading if data is loading

By monitoring the events from the Fetch Data, I can determine when the data is in the process of loading and when it's not. Utilizing these events, I display the loading status as follows:

In simple terms, I verify if the data is loading and then initiate a loading process using the Memory Pool of FSLoading. Here's how it works:

/// <summary>
/// Pool for the loading
/// </summary>
public class FSLoadingPool
{
    private FSLoading.Pool _pool;

    /// <summary>
    /// Constructor and Memory Pool is passed as an argument to cache
    /// </summary>
    /// <param name="pool">Pool to use</param>
    public FSLoadingPool(FSLoading.Pool pool)
    {
        _pool = pool;
    }

    /// <summary>
    /// Calls when need to spawn FS Loading
    /// </summary>
    /// <param name="parent">what is the parent of this UI element</param>
    /// <returns>the reference of the loading</returns>
    public FSLoading Spawn(Transform parent)
    {
        return _pool.Spawn(parent);
    }

    /// <summary>
    /// Calls when need to remove or despawn
    /// </summary>
    /// <param name="loading">item to despawn</param>
    public void Remove(FSLoading loading)
    {
        _pool.Despawn(loading);
    }
}

This refers to the loading pool. I've attached a script to the loading prefabs, which serves to provide a UI reference and update the UI based on the data. The parent of the Loading is passed as an argument during the spawn process, as shown below:

Following that, I generate a few instances in the pool using the Zenject code, as shown below:

The memory pool has been prepared and is now available. I can initiate it as required in the following manner:

The complete script is now configured for retrieval as shown below:

Last updated