Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor internal frame tracking & time handling #29

Merged
merged 19 commits into from
Sep 29, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
remove unnecessary difference between server & client side frame trac…
…king
  • Loading branch information
DavidVollmers committed Sep 27, 2023
commit 46957cc757307a647c055ee451627b7bc0a38b8e
10 changes: 1 addition & 9 deletions packages/Ignis.Components/FrameTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,19 @@

internal class FrameTracker
{
private readonly IHostContext _hostContext;

private long _currentFrame;
private long? _frameToExecuteOn;
private IgnisComponentBase? _target;
private Action? _action;

public bool IsPending => _action != null;

public FrameTracker(IHostContext hostContext)
{
_hostContext = hostContext ?? throw new ArgumentNullException(nameof(hostContext));
}

public void ExecuteOnNextFrame(IgnisComponentBase target, Action action)
{
_target = target ?? throw new ArgumentNullException(nameof(target));
_action = action ?? throw new ArgumentNullException(nameof(action));

// If we're server-side, we can just execute the action on the next render, otherwise we need to wait for the second render. (WebAssembly)
_frameToExecuteOn = _currentFrame + (_hostContext.IsServerSide ? 1 : 2);
_frameToExecuteOn = _currentFrame + 1;
}

public void OnAfterRender()
Expand Down