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

feat: Add basic infrastructure for a Context API [PROPOSAL][WIP] #3409

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

luanpotter
Copy link
Member

@luanpotter luanpotter commented Dec 14, 2024

Description

The idea is to provide some sort of "context" API for components to share render-time information with indirect descendants.

Use cases can include:

Pending some benchmarking to confirm it does not increase latency but requesting for comments on the proposed API.

Checklist

  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

@renancaraujo
Copy link
Member

Looking good. API wise it is good enough as an approach that it is not a breaking change.

It seems specific to the render phase, so I would add user-friendly error messages for when users try to access the context outside of render.
Also, should we name it RenderContext since it is so specific?

@luanpotter
Copy link
Member Author

@renancaraujo agree with both!

Copy link
Member

@spydon spydon left a comment

Choose a reason for hiding this comment

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

I'd just like some benchmark of the implication of adding this, other than that I think it looks good!

Copy link
Contributor

github-actions bot commented Jan 7, 2025

Benchmark Results

Package flame:

  • Current Branch [luan.context-api]: 2791.834 μs
  • Base Branch [main]: 2687.456 μs
  • Diff: 🔴 +3.884 %

Benchmarks provided with 💙 by Dart Benchmark Action.

@luanpotter
Copy link
Member Author

(note: I will add a bench specifically about rendering when I have some time. this was just testing the waters with the action)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants