Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

What are the best practices for lazy loading? #612

Discussion options

Assumption that an expression is dynamic, so not all the required data is known in advance.

Example:
sometimes the expression is:
foo + bar
another time can be only:
bar

If fetch for foo needs web request , how to avoid web request for each time and only fetch and set value of foo to env when found in expression?

I think it's a very normal case in business projects.For example, in a marketing system, the combination of conditions can be very flexible, and the data sources for these conditions include basic account information, order information, login information, and so on.

Different combinations of conditions require fetching different combinations of entities(Account, Order , Login...). Pre-fetching all the data every time would result in wastage of resources. It is desired to dynamically retrieve the data sources when evaluating a specific condition and cache the data sources to the environment (env).

You must be logged in to vote

@BubbleGarten @antonmedv A way to do it without patching is to replace all dynamically populated variables by 'getter's. Static variables can be used as is.
Thus, the expression becomes : getFoo() + getBar() + baz. You can have an arbitrary amount of intelligence in the getters to decide whether you want to download content or use a local cache or something else.

Replies: 2 comments 1 reply

Comment options

@antonmedv Could you please kindly provide some suggestions ?

You must be logged in to vote
1 reply
Comment options

Use patcher to replace expression to func calls:

foo() + bar()
Comment options

@BubbleGarten @antonmedv A way to do it without patching is to replace all dynamically populated variables by 'getter's. Static variables can be used as is.
Thus, the expression becomes : getFoo() + getBar() + baz. You can have an arbitrary amount of intelligence in the getters to decide whether you want to download content or use a local cache or something else.

You must be logged in to vote
0 replies
Answer selected by BubbleGarten
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

AltStyle によって変換されたページ (->オリジナル) /