Giter Club home page Giter Club logo

ember-reactive-helpers's Introduction

ember-reactive-helpers

Build Status npm version Dependency Status

Collection of helpers to aid in reactive template programming with Ember.js.

Introduction

Reactive helpers are helpers that return functions. These functions can be bound to event handlers to process data on the way up in the Data Down Actions Up cycle. r helper makes it possible to use ember-composable-helpers in event handlers where execution of the helper is delayed until event is triggered.

Helpers

(r helper [arg1 arg2 ...])

Returns a function for a given helper and curry arguments to it.

<input value={{value}} oninput={{action (pipe (r 'dasherize') (action (mut value))) value="target.value"}}

r helper accepts functions as helpers. For example, lets say you have a method on the context called addNumbers

export default Ember.Component.extend({
  addNumbers([a, b]) {
    return a + b;
  }
});

You can use it in the template.

<button {{action (pipe (r addNumbers 1) (action (mut count))) count}}>+1</button>

(r/get propName)

(r/get) helper returns a function. When called, the function will return value taken from object that it receives as first argument at property propName.

{{compute (r/get 'animal') (hash animal='cat')}} {{! //=> cat }}

(r/param [index])

(r/param) return a function. When called, this function will return received argument at specified index.

{{compute (r/param) 'hello' 'world'}} {{! //=> 'hello'}}
{{compute (r/param 1) 'hello' 'world'}} {{! //=> 'world'}}

(r/debugger)

(r/debugger) will create a helper that will inject a debugger breakpoint into a helper pipe. It will pass through the value, that's passed into the helper.

<button {{action (pipe (some-helper) (r/debugger) (some-other-helper))}}>Do!</button>

(r/log ['your message'])

(r/log) helper will evaluate to a function. When called, this function will log the passed in messsage and arguments that it received.

<button {{action (pipe (r/log 'before save') (action 'save') (r/log 'after save')) model}}>Save</button>

(r/tap value)

(r/tap value) helper will evaluate to a function that'll return the passed in argument.

{{shhh anything}}

{{shhh helper will supress any output that's passed into it. This is useful when you want to compute a helper without having it's output rendered.

(transition-to 'destination' model (query-params foo='bar'))

(transition-to) helper the same argument signature as link-to but evaluates to an action that can be called to trigger transition.

<button {{action (transtion-to 'index')}}>Go to Index</button>

(throttle action wait [immidiate])

(throttle) helper will ensure that the action is only triggered once per given wait period. The action will be triggered at the end of the wait period unless immidate is set to true.

<button {{action (throttle (action 'increment') 100)}}>+1</button>

(debounce action wait [immidiate])

(debounce) helper waits for specified time to pass before triggering callback. All intemidiate events are discarded.

<button {{action (debounce (pipe (r 'add' 1) (action (mut count)) ) 100) count}}>+1</button>

Installation

ember install ember-reactive-helpers

Helpful Links

Looking for help?

If it is a bug please open an issue on GitHub.

Usage

ember-reactive-helpers's People

Contributors

taras avatar ember-tomster avatar

Watchers

James Cloos avatar Dale Ma avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.