Mini MVVM Framework Avalonjs Learning Tutorial 15, attribute monitoring and module communication

Source: Internet
Author: User
Tags button type

Avalon's ViewModel object inherits three methods from its internal eventmanager , $watch, $unwatch, $fire three methods that are the subject of our section.

Words, like their name, are very straightforward and know what to do at a glance. Let's start with the $watch method, which listens to the monitoring and calculation Properties of the first layer of the current VM, and if an attribute is an object that wants to monitor its descendants ' properties, it needs to navigate to the object using the $watch callback. The $watch callback defaults to the two attribute values that are passed in.

<! DOCTYPE html><! DOCTYPE html><! DOCTYPE html>

Note that the $watch callback is the new API object.is provided by ecma262 V6 , which has the same function as = = = , but can deal with NaN This himself is not equal to his own freak. Also, an object literal, even if it looks the same, is a new object and will not be equal to the original.

<! DOCTYPE html>

For arrays, we can only listen for changes in the length of the array, and cannot listen for changes in its interior.

<! DOCTYPE html><! DOCTYPE html>

    • Up!xxx, bubble up.
    • Down!xxx, capturing down
    • ALL!XXX, Global Broadcast
<! DOCTYPE html>

Mini MVVM Framework Avalonjs Learning Tutorial 15, attribute monitoring and module communication

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.