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

Evaluate lazily Android specific global values #2002

Merged
merged 1 commit into from Apr 21, 2016

Conversation

jasssonpet
Copy link
Contributor

Related to: #1563

ping @atanasovg, @KristinaKoeva

@jasssonpet jasssonpet self-assigned this Apr 20, 2016
@jasssonpet jasssonpet added this to the 2.0.0 milestone Apr 20, 2016
@ns-bot ns-bot added cla: yes and removed cla: no labels Apr 20, 2016
@jasssonpet jasssonpet changed the title Evaluate lazily android specific global values Evaluate lazily Android specific global values Apr 20, 2016
@@ -31,7 +32,7 @@ export function _clearForwardTransitions(fragment: any): void {
fragment[EXIT_POPENTER_TRANSITION] = undefined;
}

if (_sdkVersion >= 21) {
if (_sdkVersion() >= 21) {
Copy link
Contributor

Choose a reason for hiding this comment

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

error TS2365: Operator '>=' cannot be applied to types '() => number' and 'number'.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll take a look. It's compiling fine on my machine, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@enchev This is fixed now.

@hamorphis
Copy link
Contributor

Sounds very neat.

@atanasovg
Copy link
Contributor

👍

2 similar comments
@PanayotCankov
Copy link
Contributor

👍

@hshristov
Copy link
Contributor

👍

let _value: T;
return () => _value || (_value = action());
})();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we reuse the outer scope :D

export default function lazy<T>(action: () => T): () => T {
    let cache: T;
    return () => cache || (cache = action());
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@PanayotCankov Yeah, the self-executing function is redundant.

@hdeshev
Copy link
Contributor

hdeshev commented Apr 21, 2016

A premature optimization on my end - maybe we can move the lazy function to the "globals" module to avoid require-ing the module all over the place (the same thing we did for moduleMerge)

👍

@jasssonpet
Copy link
Contributor Author

@hdeshev I like your suggestion, but let's push forward the webpack plugin. It will resolve such issues.

@jasssonpet jasssonpet merged commit 98e8a52 into master Apr 21, 2016
@jasssonpet jasssonpet deleted the jasssonpet/lazy-snapshot branch April 21, 2016 14:56
@vchimev vchimev restored the jasssonpet/lazy-snapshot branch April 21, 2016 15:28
@vchimev vchimev deleted the jasssonpet/lazy-snapshot branch April 21, 2016 15:28
@lock
Copy link

lock bot commented Aug 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Aug 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants