Created by Ryan LaBouve / @ryanlabouve
"the principle that any changes to application state are reflected immediately to the user, visually or otherwise."
Charles Lowell, Reactive Modeling with Ember
Two Static Properties (A,B) and a Visualized Dyamic Relationship
Adobe Color CC
This principle of instant feedback is what makes reactive interfaces... so low friction because the consequences of any action are immediately understood. This encourages the user to experiment and probe the relationships between the data in your application. They can “play” in order to verify or invalidate hypotheses.
Charles Lowell, Reactive Modeling with Ember
Visualize Dynamic Relationships
Ember.Model
Ember.computed
What we're looking for
Ember.Object
Ember.computed
For the reactive part
Primitive #1
// Setter and Getter Required for Observation
const human = Ember.Object.create({});
human.set('name', 'bob');
human.get('name'); // => "name"
// app/application/route
import Ember from 'ember';
const Human = Ember.Object.extend();
export default Ember.Route.extend({
model() {
return Human.create({ firstName: 'bob' });
}
});
{{! app/templates/application.hbs }}
Why, hello there {{model.firstName}}!
First Name:
{{input value=model.firstName}}
Primitive #2
import Ember from 'ember';
const { computed } = Ember;
const Human = Ember.Object.extend({
fullName: computed( 'firstName', 'lastName', function() {
return `${this.get('firstName')} ${this.get('lastName')}`;
})
});
export default Ember.Route.extend({
model() {
return Human.create({ firstName: 'bob', lastName: 'smith' });
}
});
Why, hello there {{model.fullName}}!
First Name:
{{input value=model.firstName}}
{{input value=model.lastName}}
Yey lazy evaluation! Mike North, Compose All the Things
Forming more complex reactive relationships
import Ember from 'ember';
import EmberCPM from 'ember-cpm';
const { Macros: { sum, difference, product }} = EmberCPM;
export default Ember.Component.extend({
num1: 45,
num2: 3.5,
num3: 13.4,
num4: -2,
total: sum(
sum('num1', 'num2', 'num3'),
difference('num3', 'num2'),
product(difference('num2', 'num1'), 'num4')
)
});
With great power...
I'm tired of figuring out how much to eat.
Harris Benedict Equation is a formula that uses your BMR and then applies an activity factor to determine your total daily energy expenditure (calories)
Activivty Level | Formula |
---|---|
none | = BMR x 1.2 |
light | = BMR x 1.375 |
moderate | = BMR x 1.55 |
intense | = BMR x 1.725 |
ultra brutal | = BMR x 1.9 |
The BMR formula uses the variables of height, weight, age and gender to calculate the Basal Metabolic Rate (BMR)
Women:http://www.bmi-calculator.net/bmr-calculator/bmr-formula.php
BMR = 655 + ( 4.35 x weight, lbs ) + ( 4.7 x height, inches ) - ( 4.7 x age, years )
Men:
BMR = 66 + ( 6.23 x weight, lbs) + ( 12.7 x height, inches ) - ( 6.8 x age, year )
How much to eat based on amount of activity
https://github.com/ryanlabouve/how-much-to-eat-example
ember new how-much-to-eat
ember install ember-cli-sass
ember install ember-paper
npm install ember-cpm --save-dev
ember generate route application
ember generate controller application
ember serve