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

GRAFX-3507 Support multiple event handlers #482

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

pietervp
Copy link
Member

@pietervp pietervp commented Jul 11, 2024

Problem

When using the SDK, we expose a lot of event handlers to the integrator. For example, we can execute a callback whenever the selected frame changed. There is one big (not obvious) caveat, the handler can only be defined once. This means that each event can only be handled by 1 consumer. This is especially bad when using studio-ui, and you want to tap into some of these event yourself as integrator. Once you do that, you probably have broken the studio-ui interface by overriding it’s subscription.

Proposal

  • Deprecate all properties in SDK.config.on and move logic to SDK.config.events where each property on will no longer be a simple callback, but a class to manage subscriptions.
  • Remain backwards compatible, the events properties will by default use the legacy SDK.config.on callback when the event is triggered. We also keep supporting overriding that handler.
  • Follow Up: Workspace and studio-ui should move to the events based approach when registering event handlers. (first we need SDK PR)

Code Highlights

Open Questions

  • Naming: do we keep SDK.config.events or are there better naming options?
  • Naming: do we keep SDK.config.handlers to indicate callbacks that require to return a result

@pietervp pietervp requested review from a team as code owners July 11, 2024 07:10
Copy link
Contributor

Coverage Report

Coverage report can be checked at https://stgrafxstudiodevpublic.blob.core.windows.net/sdk/coverage/482/coverage.html

Use PR sdk package

Tarball can be downloaded from https://stgrafxstudiodevpublic.blob.core.windows.net/sdk/dev-packages/482/studio-sdk.tgz

To use in local project, change package.json to use local tarball

"dependencies": {
    "@chili-publish/studio-sdk": "https://stgrafxstudiodevpublic.blob.core.windows.net/sdk/dev-packages/482/studio-sdk.tgz"
}

Copy link
Contributor

github-actions bot commented Jul 11, 2024

Unit Test Results

    1 files    40 suites   44s ⏱️
439 tests 439 ✔️ 0 💤 0
444 runs  444 ✔️ 0 💤 0

Results for commit 65a5dca.

♻️ This comment has been updated with latest results.

@Matthiee Matthiee self-requested a review July 11, 2024 08:08
Copy link
Member

@Matthiee Matthiee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this idea 💯

I do have some concerns regarding the naming.

packages/sdk/src/utils/EventSubscription.ts Outdated Show resolved Hide resolved
packages/sdk/src/utils/EventSubscription.ts Outdated Show resolved Hide resolved
packages/sdk/src/utils/EventSubscription.ts Outdated Show resolved Hide resolved
packages/sdk/src/utils/EventSubscription.ts Outdated Show resolved Hide resolved
packages/sdk/src/utils/EventSubscription.ts Outdated Show resolved Hide resolved
packages/sdk/src/utils/EventSubscription.ts Outdated Show resolved Hide resolved
@pietervp
Copy link
Member Author

After receiving feedback from @Matthiee and discussing offline with @brapoprod :

Matthiee
Matthiee previously approved these changes Jul 18, 2024
packages/sdk/src/utils/EngineCallbackHandler.ts Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants