I know one is a reactive source, while the other is not. But I thought they would always give the same value.
Then I found the following code in Telescope's source:
var newTerms = Template.currentData().terms; // ⚡ reactive ⚡
if (!_.isEqual(newTerms, instance.data.terms)) {
instance.postsLimit.set(instance.data.terms.limit || Settings.get('postsPerPage', 10));
}
link: https://github.com/TelescopeJS/Telescope/blob/master/packages/telescope-posts/lib/client/templates/posts_list/posts_list_controller.js#L33
So it seems these two values can sometimes differ. When?
Default template defines a look and feel, basically a style of control. That's why by default, Button or TextBox shapes are ectangular because it is defined in its default template. Now we can update that template and add our own implementation. Data Template: Customize the functionality.
Default data templates Configuration data templates are predefined lists of entities for each module area that can be used in a data project. You can create, view, and modify these templates by using the Template page in the Data management workspace.
But you can do the same in the code behind. We need to use ContentPresenter when we want to use DataTemplate. Then you must specify its content, and the source from where our inner control is supposed to fetch its data. Then bind each property as you wish. I hope this article has helped you to understand Templates in WPF.
A DataTemplate, therefore, is used to provide visual structure for underlying data, while a ControlTemplate has nothing to do with underlying data and simply provides visual layout for the control itself.
According to Meteor's documentation, about template.data
:
This property provides access to the data context at the top level of the template. It is updated each time the template is re-rendered. Access is read-only and non-reactive.
Since we know that the current data context is reactive, hence can change without the template being re-rendered (which is what makes reactivity look all nice and smooth on Blaze), this if
statement is written to check if the "real" current terms (which are stored in the reactive Template.currentData()
) have changed compared to the "previous" terms we had the last time the current template was rendered. (stored in the non-reactive template.data
)
To wrap it up, what this autorun does is:
template.data
when the template was renderedIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With