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

Add CachedIterable.from #3

Merged
merged 2 commits into from
Jun 8, 2018
Merged

Add CachedIterable.from #3

merged 2 commits into from
Jun 8, 2018

Conversation

stasm
Copy link
Contributor

@stasm stasm commented Jun 8, 2018

The static method from() may be used to create new CachedIterable instances from other iterables (which is the same as using the constructor) or to re-use existing ones. When an existing instance of CachedIterable is passed, from() simply returns it, preserving its cached state.

The use-case is fluent-react and projectfluent/fluent.js#100. The Localization class by default wraps the iterable of contexts it receives in a CachedAsyncIterable. At the same time, the user of fluent-react might want to prefetch some contexts from that iterable before handing it off to Localization.

Fixes #2.

stasm added 2 commits June 8, 2018 16:30
It behaves similar to the constructor. It can also detect instances of
CachedSyncIterable and CachedAsyncIterable passed as the argument and if the
argument's class matches the class from() was called on, it returns the
argument unmodified.
@stasm stasm requested a review from zbraniecki June 8, 2018 16:42
Copy link
Collaborator

@zbraniecki zbraniecki left a comment

Choose a reason for hiding this comment

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

lgtm

@stasm stasm merged commit dca60f8 into master Jun 8, 2018
@stasm stasm deleted the from branch June 8, 2018 18:39
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.

None yet

2 participants