Skip to content

Commit 3a71761

Browse files
committed
Added methods
1 parent 9c9d847 commit 3a71761

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

Runtime/Loading/Services/ILoadingService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public interface ILoadingService
1111
void AddBeforeLoading(Func<CancellationToken, Task> func);
1212
void AddAfterLoading(Func<CancellationToken, Task> func);
1313

14-
void EnqueueLoad(params Func<CancellationToken, Task>[] func);
14+
void Enqueue(params Func<CancellationToken, Task>[] functions);
15+
void Enqueue(params Action[] actions);
1516
}
1617
}

Runtime/Loading/Services/LoadingService.cs

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,41 @@ public void AddBeforeLoading(Func<CancellationToken, Task> func)
2525
afterLoad.Add(func);
2626
}
2727

28-
public void EnqueueLoad(params Func<CancellationToken, Task>[] func)
28+
public void Enqueue(params Func<CancellationToken, Task>[] functions)
2929
{
30-
if(sequencer.Count == 0)
30+
OnStartLoading();
31+
32+
foreach (Func<CancellationToken, Task> function in functions)
3133
{
32-
IsLoading = true;
34+
sequencer.Play(function);
35+
}
36+
}
3337

34-
sequencer.OnComplete -= OnComplete;
35-
sequencer.OnComplete += OnComplete;
38+
public void Enqueue(params Action[] actions)
39+
{
40+
OnStartLoading();
41+
42+
foreach (Action action in actions)
43+
{
44+
sequencer.Play(action);
45+
}
46+
}
3647

37-
foreach (Func<CancellationToken, Task> before in beforeLoad)
38-
{
39-
sequencer.Play(before.Invoke);
40-
}
48+
private void OnStartLoading()
49+
{
50+
if(sequencer.Count > 0)
51+
{
52+
return;
4153
}
4254

43-
foreach (Func<CancellationToken, Task> toLoad in func)
55+
IsLoading = true;
56+
57+
sequencer.OnComplete -= OnComplete;
58+
sequencer.OnComplete += OnComplete;
59+
60+
foreach (Func<CancellationToken, Task> before in beforeLoad)
4461
{
45-
sequencer.Play(toLoad);
62+
sequencer.Play(before.Invoke);
4663
}
4764
}
4865

0 commit comments

Comments
 (0)