Meteor: Component Ideas

Source: Internet
Author: User

Inspired by react component ideas, this paper discusses the application of component-based thinking in Meteor client, taking SPACEBAR template language as an example.

The so-called front-end component (my definition) is the encapsulation of a set of HTML code and related styles and behaviors. It can be reused, initialized by passing parameters, and can be controlled by invoking its defined methods. And, its state, styles are locally encapsulated, do not spread and affect the global.

Typically, a component has data and states (called props and statues in react). Data is an external pass-through that is used to build and render components that are immutable throughout the lifetime of the component instance. States is the state of a component's internal encapsulation, which assists in controlling the behavior of the component, and the behavior and rendering of the component are two-way bound and externally transparent, and the component can expose the state externally in the form of a method or callback.

Meteor can encapsulate components in the form of a template. Template can have data and instance variables, you can use the template data to implement the component, and use reactive template instance variable to implement the component States. Specific implementation mode reference http://www.cnblogs.com/zhaoyao91/p/4535928.html

Todo

How to implement a component method or callback for external fetch state, temporarily do not think well. The possible approach is that the parent component passes the callback function to the subassembly via data

Meteor: Component Ideas

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.