<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Apis on Featherₜₛ</title>
    <link>//www.feather-ts.com/api/index.xml</link>
    <description>Recent content in Apis on Featherₜₛ</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Sat, 01 Oct 2016 21:07:13 +0100</lastBuildDate>
    <atom:link href="//www.feather-ts.com/api/index.xml" rel="self" type="application/rss+xml" />
    
    <item>
      <title>API Documentation</title>
      <link>//www.feather-ts.com/api/</link>
      <pubDate>Sat, 01 Oct 2016 21:07:13 +0100</pubDate>
      
      <guid>//www.feather-ts.com/api/</guid>
      <description>

&lt;h2 id=&#34;widgets&#34;&gt;Widgets&lt;/h2&gt;

&lt;p&gt;Your application will be a collection of classes that all extend feather&amp;rsquo;s Widget class. The widget class itself inherits
other classes in the following order:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;MyWidget -&amp;gt; Widget -&amp;gt; Observable -&amp;gt; RouteAware -&amp;gt; Subscribable -&amp;gt; EventAware -&amp;gt; Object
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&#34;widget&#34;&gt;Widget&lt;/h3&gt;

&lt;p&gt;At its core a widget class is attached to a single DOM element. It holds a reference to that element, which you can access
in your class via &lt;code&gt;this.element&lt;/code&gt;. Furthermore it exposes a method &lt;code&gt;render(templateName: string)&lt;/code&gt;, which has to be
called manually for the widget to render into its element. Feather doesn&amp;rsquo;t want to make assumption when to render the
widget; it might be required to fetch data from a server or wait for other events first.&lt;/p&gt;

&lt;p&gt;A widget usually comes with a &lt;code&gt;@Construct({selector: string})&lt;/code&gt; class annotation, which defines which HTML elements the
component will be attached to. Once the Widget cas been created, you can override the &lt;code&gt;init(element: HTMLElement)&lt;/code&gt; method
in your class and call this.render(templateName) there. The templateName is defined via &lt;code&gt;@Template()&lt;/code&gt;, which should
decorate a method which returns a string it should render. Note the widgets don&amp;rsquo;t require a constructor, and most of the
custom initialization should be done in the overwritten &lt;code&gt;init&lt;/code&gt; method. An exception to this are array-widgets, but more
on this later.&lt;/p&gt;

&lt;p&gt;You can also have different templates in the same widget class and choose which way to render the widget&amp;rsquo;s data.&lt;/p&gt;

&lt;p&gt;Putting it all together, a very simple widget might look like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt; module demo {
 
     import Widget    = feather.core.Widget
     import Construct = feather.annotations.Construct
     import Template  = feather.annotations.Template
 
     @Construct({selector: &#39;body&#39;})
     export class MyApplication extends Widget {
 
         who = &#39;world&#39;   
 
         init(element: HTMLElement) {
             this.render(&#39;default&#39;)
         }
 
         @Template(&#39;default&#39;)
         protected getBaseTemplate() {
             return (`
                Hello ${this.who}!                                    
             `)
         }
     }
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Call then &lt;code&gt;feather.start()&lt;/code&gt; and your application should render itself into &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;h2 id=&#34;observable&#34;&gt;Observable&lt;/h2&gt;

&lt;h3 id=&#34;primitives&#34;&gt;Primitives&lt;/h3&gt;

&lt;p&gt;The above example is quite rudimentary and if you wanted to change the variable &lt;code&gt;who&lt;/code&gt; you would need to call &lt;code&gt;render(...)&lt;/code&gt; again to see it.
This is a little bit cumbersome and expensive, since the widget would then re-render the entire template with any sub widgets referenced within. To
avoid this you can annotate primitive members (currently only booleans, strings and numbers) with &lt;code&gt;@Bind()&lt;/code&gt; like this (note the use of double-curlies):&lt;/p&gt;

&lt;script async src=&#34;//jsfiddle.net/phbw6sdj/1/embed/js,result/&#34;&gt;&lt;/script&gt;

&lt;p&gt;Now whenever the value of &lt;code&gt;who&lt;/code&gt; changes, the text node will update automatically. You can bind variables in 4 different places within
a dom tree and in combation with the variable type, only some of them make sense. The hooks can be inserted in these ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;div class=&amp;quot;right {{variable}} large&amp;quot;&amp;gt;...&amp;lt;/div&amp;gt;&lt;/code&gt; As a new class in the class attribute (only strings)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;div class=&amp;quot;red&amp;quot; style=&amp;quot;{{variable}}&amp;quot;&amp;gt;...&amp;lt;/div&amp;gt;&lt;/code&gt; Within an arbitrary attribute (only strings and booleans)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;div class=&amp;quot;red&amp;quot; {{variable}}&amp;gt;...&amp;lt;/div&amp;gt;&lt;/code&gt; As a property hook (booleans and arrays)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;div class=&amp;quot;red&amp;quot;&amp;gt;Some {{variable}} text!&amp;lt;/div&amp;gt;&lt;/code&gt; Within a text node (only strings)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note that any binding can convert booleans, numbers or arrays into strings. This is done but declaring a &amp;ldquo;filter&amp;rdquo; function in the widget
class. you can then bind it like this: &lt;code&gt;&amp;lt;div class=&amp;quot;{{variable:formatAsString}}&amp;quot;&amp;gt;...&amp;lt;/div&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;h3 id=&#34;booleans&#34;&gt;Booleans&lt;/h3&gt;

&lt;h3 id=&#34;arrays&#34;&gt;Arrays&lt;/h3&gt;

&lt;h3 id=&#34;objects&#34;&gt;Objects&lt;/h3&gt;

&lt;p&gt;&amp;hellip; write the rest &amp;hellip;&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>