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

Support lazy context data #324

Merged
merged 3 commits into from
Jul 29, 2022
Merged

Support lazy context data #324

merged 3 commits into from
Jul 29, 2022

Conversation

djbe
Copy link
Contributor

@djbe djbe commented Jul 28, 2022

This adds support for providing lazily calculated context data. It provides 3 ways of doing this:

  • Plain lazy data, when you don't need the context: LazyValueWrapper(someMagicStuff())
  • Lazy data using context: LazyValueWrapper { context in … }
  • Lazy data using a copy of the context (for example in custom tags): LazyValueWrapper(copying: context) { context in … }

An example where this is useful is in SwiftGen, where we want to avoid doing some heavier metadata parsing that most users won't need. We made our own implementation, which can be replaced with this PR.
https://github.com/SwiftGen/SwiftGen/blob/stable/Sources/SwiftGenKit/Stencil/ContextHelpers.swift

@djbe djbe added this to the 0.15.0 milestone Jul 28, 2022
@SwiftGen-Eve
Copy link

SwiftGen-Eve commented Jul 28, 2022

Hey 👋 I'm Eve, the friendly bot watching over Stencil 🤖

Thanks a lot for your contribution!


Seems like everything is in order 👍 You did a good job here! 🤝

Generated by 🚫 Danger

@djbe djbe force-pushed the feature/lazy-data branch 7 times, most recently from 0e254e1 to 27c10c0 Compare July 29, 2022 00:04
@djbe djbe force-pushed the feature/lazy-data branch from 27c10c0 to 5f0c018 Compare July 29, 2022 01:07
@djbe djbe merged commit 078c7a8 into master Jul 29, 2022
@djbe djbe deleted the feature/lazy-data branch July 29, 2022 15:53
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.

2 participants