all files / documents/document/ state-mixin.js

100% Statements 7/7
100% Branches 0/0
100% Functions 2/2
100% Lines 7/7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22              19×       18×          
import Ember from 'ember';
import { keys } from './internal/state';
 
const {
  computed,
  assign
} = Ember;
 
const getters = keys.reduce((obj, key) => {
  obj[key] = computed(function() {
    return this._internal.state[key];
  }).readOnly();
  return obj;
}, {});
 
const state = computed(function() {
  return this._internal.state.get();
}).readOnly();
 
export default Ember.Mixin.create(assign({}, getters, { state }));