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

&lt;h2 id=&#34;installing-featherₜₛ&#34;&gt;Installing Featherₜₛ&lt;/h2&gt;

&lt;p&gt;Installing &lt;a href=&#34;https://github.com/Microsoft/TypeScript&#34;&gt;typescript&lt;/a&gt; and &lt;a href=&#34;https://github.com/typings/typings&#34;&gt;typings&lt;/a&gt; globally is recommended, if not yet present. Then run the following commands to add featherₜₛ as a
local dependency.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;npm install feather-ts --save
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Create a &lt;strong&gt;tsconfig.json&lt;/strong&gt; file in your project&amp;rsquo;s root containing the following settings. ES6 output is currently not supported and
since decorators are the beef of it all make sure they are enabled. Feather.js embeds the typescript emitted helpers so you can disable
them if you wish.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;{
  &amp;quot;compilerOptions&amp;quot;: {
    ...
	&amp;quot;target&amp;quot;: &amp;quot;es5&amp;quot;, 
	&amp;quot;experimentalDecorators&amp;quot;: true, 
	...
  },
  &amp;quot;files&amp;quot;: [
	&amp;lt;your-source-files&amp;gt;
  ],
  &amp;quot;exclude&amp;quot;: [
    ...
	&amp;quot;node_modules&amp;quot;,
	&amp;quot;typings&amp;quot;
	...
  ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then write your widgets and include the output together with feather.js (from node_modules) in your page.
After the DOM and the scripts have been loaded make the following call; it will bootstrap the widgets and route listeners.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;feather.start();
&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id=&#34;a-widget-s-anatomy&#34;&gt;A widget&amp;rsquo;s anatomy&lt;/h2&gt;

&lt;p&gt;To get an impression of the code style you will be dealing with, here is a sample widget code. As you can see the code is
very compact and flat.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;module todomvc.feather {

    import Widget          = feather.core.Widget /* imports of referenced components */
    ...
    
    @Construct({selector: &#39;.todoapp&#39;}) /* the selector to bind this widget to */
    class TodoList extends Widget {    /* all widgets must extend Widget */

        @Bind() state = ListState.ALL  /* prefix members that auto update DOM with @Bind(), supported are booleans, strings and numbers */

        @Bind({templateName: &#39;default&#39;, changeOn: [&#39;state&#39;]}) /* arrays are a special case, more about the params later */
        todos: Todo[] = []
        
        /* no constructor is required */

        init(element: HTMLElement) {   /* whenever a widget is fully initialized it calls init() */
            this.getData()
        }
        
        @Fetch(&#39;/api/todos&#39;)           /* fetch data from a REST api and render the widget */
        getData(data?: Todo[]) {
            this.todos.push.apply(this.todos, data)
            this.render(&#39;default&#39;)     /* if you&#39;re not loading data you can render() already in init() */
        }

        @Subscribe(&#39;create-todo&#39;)      /* listen to messages from parent or child widgets via @Subscribe */
        newTodo(todo: Todo) {
            this.todos.push(todo)
        }

        @Route(&#39;/:path&#39;)               /* listen to route changes with @Route */
        locationPath(params: SimpleMap) {
            if (params[&#39;path&#39;] === &#39;active&#39;) {
                ...
            }
        }

        @On({event: &#39;click&#39;, selector: &#39;.clear-completed&#39;, preventDefault: true}) /* attach DOM events via @On */
        clearCompleted() {
            ...
        }

        @Template(&#39;default&#39;) /* widgets can be rendered with different templates */
        toHtml() { /* use ES6 template strings to define HTML snippets */
            return (`
              ...
              &amp;lt;ul class=&amp;quot;todo-list&amp;quot; {{todos:listFilter}}&amp;gt;&amp;lt;/ul&amp;gt;
              &amp;lt;button class=&amp;quot;clear-completed&amp;quot; hidden=&amp;quot;{{todos:noCompleted}}&amp;quot;&amp;gt;Clear completed&amp;lt;/button&amp;gt;
              ...
            `)
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;See the full todo app in action &lt;a href=&#34;http://todo.feather-ts.com/&#34;&gt;here&lt;/a&gt;. Take a peek at the typescript source maps, too.&lt;/p&gt;

&lt;div class=&#34;admonition note&#34;&gt;
&lt;p class=&#34;admonition-title&#34;&gt;Note&lt;/p&gt;
&lt;p&gt;The bindings in the HTML code are very simple. The only extra syntax on top of regular HTML is {{variable:methodA:methodB}}. Methods
are optional however they can convert values to other types, ie boolean to &amp;ldquo;yes&amp;rdquo; / &amp;ldquo;no&amp;rdquo; strings, or filter arrays before rendering.&lt;/p&gt;

&lt;p&gt;The above code is stripped off large parts, so don&amp;rsquo;t expect it to compile or run.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <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>
    
    <item>
      <title>Image layout algorithm</title>
      <link>//www.feather-ts.com/example/</link>
      <pubDate>Sun, 02 Oct 2016 21:07:13 +0100</pubDate>
      
      <guid>//www.feather-ts.com/example/</guid>
      <description>&lt;p&gt;Here we are going to use feather to write a small widget that layouts a set of images in an rectangle with fixed dimensions.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Introduction</title>
      <link>//www.feather-ts.com/</link>
      <pubDate>Thu, 29 Sep 2016 21:07:13 +0100</pubDate>
      
      <guid>//www.feather-ts.com/</guid>
      <description>&lt;p&gt;Featherₜₛ is a small component framework written in &lt;a href=&#34;https://www.typescriptlang.org/&#34;&gt;TypeScript&lt;/a&gt;.
Whether you are writing embeddable javascript widgets or a single page application this framework
might be of use. With less than 8kb in size it is suited for mobile apps and desktop alike.
It is especially well suited for the consumption of restful services.&lt;/p&gt;

&lt;p&gt;The framework offers the following features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Each component is holding logic, view and model in a single file&lt;/li&gt;
&lt;li&gt;Components automatically build a hierarchical tree&lt;/li&gt;
&lt;li&gt;Message hub between components&lt;/li&gt;
&lt;li&gt;REST access&lt;/li&gt;
&lt;li&gt;Routing via hash or history API&lt;/li&gt;
&lt;li&gt;Very flat learning curve due&lt;/li&gt;
&lt;li&gt;Logicless templates in pure HTML with very simple binding syntax&lt;/li&gt;
&lt;li&gt;Event delegation out of the box&lt;/li&gt;
&lt;li&gt;Written in TypeScript&lt;/li&gt;
&lt;li&gt;No module loaders needed, embed directly via NPM&lt;/li&gt;
&lt;li&gt;With aynchronous decorators no need for &lt;em&gt;promises&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Support for modern browsers including IE9
&lt;br /&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can checkout a todomvc demo &lt;a href=&#34;http://todo.feather-ts.com&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&#34;admonition note&#34;&gt;
&lt;p class=&#34;admonition-title&#34;&gt;Note&lt;/p&gt;
&lt;p&gt;This project is in its infancy, so if you want something production ready, you
should probably check out react, angular or any of the myriad of MVC frameworks out there with way
better documenation and community support than feather will ever have.&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;As soon as the framework is stable enough to be released to the public I will disclose the github repository.
Right now it is just work in progress, thus use it at your own risk. If you find any problems feel free to
drop me an &lt;a href=&#34;mailto:mendrik76@gmail.com&#34;&gt;email&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>