smalljs$molSearch⌘ KDocsPlaygroundCompareEcosystemAboutEN
From TypeScript to view.treeGetting StartedIntroductionMental modelGetting StartedFrom TypeScript to view.treeProject StructureToolingEssentialsInstallationViewsState & ReactivityRoutingRenderingTestingDeploymentTroubleshootingDataData FetchingData SchemasGiper BazaMoreShowcaseFrom React, Vue & SvelteCookbookAdvancedPluginsModule metadataOfflineGhost viewsAboutFAQTeamReleasesAPI$mol_button_major$mol_button_minor$mol_string$mol_number$mol_text$mol_paragraph$mol_list$mol_row$mol_link$mol_check$mol_switch$mol_select$mol_scroll$mol_page$mol_pick

From TypeScript to view.tree

The component you wrote in Getting Started is a plain TypeScript class. It compiles, it runs, and it is a supported way to describe a $mol component — one of several the framework accepts.It also asked you to keep four things in your head that had nothing to do with what the component does. This page takes them one at a time and shows the line of view.tree that removes each one. Then it shows the code the compiler generates, so you can check that the tree is not a second runtime: it produces the class you already wrote.Here is that file again, to compare against:1namespace $ {2 3 export class $my_hello extends $mol_page {4 5 title() {6 return 'Greeting'7 }8 9 body() {10 return [ this.Name(), this.Message() ]11 }12 13 @ $mol_mem14 Name() {15 const obj = new this.$.$mol_string16 obj.hint = () => 'Enter your name'17 obj.value = ( next?: string ) => this.name( next )18 return obj19 }20 21 @ $mol_mem22 name( next?: string ) {23 return next ?? ''24 }25 26 @ $mol_mem27 Message() {28 const obj = new this.$.$mol_view29 obj.sub = () => [ this.greeting() ]30 return obj31 }32 33 greeting() {34 const name = this.name()35 return name ? `Hello, ${ name }!` : 'Please enter your name'36 }37 38 }39 40}
Edit this page on GitHubWas this helpful?YesNoPreviousGetting StartedNextProject Structure
On this pageThe child is yours to build, and yours to cacheThe operator says which way the data movesTwo-way binding is one keystroke away from silently read-onlyA localized string stays a string until you make it a keyThe whole componentWhat the compiler emitsWhat a hand-written class cannot hand to a toolThe size of itWhich one to write
Type to search the documentation.