# Introduction

## What is Web Atoms?

"Web Atoms" is an light weight advanced MVU framework to write web applications in HTML5. Using JavaScript modules, you can divide large app into smaller modules, also offer localization using modules with reduced app size.

## Requirements
1. TypeScript or JavaScript
2. NodeJS with NPM

## UMD Loader
All web atoms modules are transpiled in SystemJS module, however for optimized performance, we recommend using web atom's own module loader.

```html
<html>
    <head>
        <title>Web Atoms Core Samples</title>
        <!-- AMD Loader -->
        <script type="text/javascript" src="./node_modules/@web-atoms/module-loader/umd.js"></script>
    </head>
    <body>
        <script type="text/javascript">

            // map path of Application Package
            // all dependencies will be loaded from
            // node_modules folder inside Application Package
            UMD.setupRoot("@web-atoms/samples", "./");

            // set language
            UMD.lang = "en-US";

            // Load view in entire page, this method will
            // resolve package from the above mentioned map of 
            // package to url. And it will create an instance of
            // App class and it will host the view `AppHost` in the
            // body of this document
            UMD.loadView(
                /** Path to module (node resolution style) */
                "@web-atoms/samples/dist/web/views/AppHost",
                /** Design Mode to enable mock*/
                false /*true*/);
        </script>
    </body>
</html>
```

# Atom Control
AtomControl is the root class, which offers data binding, event re-routing and disposables. AtomControl can contain multiple html elements and each element can have its own different binding.

```tsx
export default class TaskList extends ContentPage {

    public search = "";

    // simple dependency injection
    @InjectProperty
    private taskService: TaskService;

    public async init() {

        // two way binding
        // so whenever the value is updated
        // search will be set, and anyone
        // watching it, will refresh.
        this.headerRenderer = () => <div data-layout="row">
            <input value={Bind.twoWaysImmediate(() => this.search)}/>
        </div>;

        // automatically refresh items
        // if search was updated.
        // It will also load items first time.
        this.render(<div>
            <AtomRepeater
                items={Bind.oneWayAsync((c, e, cancelToken) =>
                    this.taskService.search(this.search, cancelToken)
                )}
                itemRenderer={(item) => <TaskView task={item}/>}
                />
        </div>);
    }
}
```

In above example, `Bind.oneWayAsync` will watch for any changes in `this.search` and as soon as it gets updated, it will execute the function, however if the previous execution is still in process, 3rd parameter (cancelToken) can be used to abort the search.

`Bind.twoWaysImmediate` will cause `this.search` to be set whenever user makes any changes.