You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!-- Context should contain a field 'text' -->
<template name="paragraph">
{{#if th_containsBadWords}}
<p>You are too young to view this paragraph.</p>
{{else}}
<p>{{th_translatedText}}</p>
{{/if}}
</template>
Template.blogPost.th_containsBadWords = function() {
return MySafeText.containsBadWords(this.text);
}
Template.blogPost.th_translatedtext = function() {
return i18n.translate(this.text);
}
Suppose the following course of action:
Initially, 'text' does not contain any bad word and is displayed normally.
Then 'text' is updated in the database with a value containing a bad word.
Because th_containsBadWords and th_translatedtext are reactive computations depending on 'text', they might both be triggered.
But because th_containsBadWords has been declared first, it is executed first, removing the very need of calling th_translatedText (which is good).
Using isolateValue :
th_containsBadWords can benefit from isolateValue, for example to avoid refreshing the {{if}} block every time 'text' is changed with an additional bad word.
Not using isolateValue :
Suppose the following course of action:
th_containsBadWords
andth_translatedtext
are reactive computations depending on 'text', they might both be triggered.th_containsBadWords
has been declared first, it is executed first, removing the very need of callingth_translatedText
(which is good).Using isolateValue :
th_containsBadWords
can benefit from isolateValue, for example to avoid refreshing the{{if}}
block every time 'text' is changed with an additional bad word.This is a huge progress over the previous version.
However there is a drawback: it seems isolateValue has changed the reactive computation order.
Here is what I see when using the new
th_containsBadWords
:th_containsBadWords
andth_translatedtext
are reactive computations depending on 'text', they might both be triggered.th_translatedText
is called first, which is useless.th_containsBadWords
is called next, hiding the text we have just translated.We can put things back in order by changing also
th_translatedText
like this:But this looks ugly.
Any idea? Am I wrong somewhere? (notice that I use Meteor 0.8.3.)
The text was updated successfully, but these errors were encountered: