| 71 | } |
| 72 | |
| 73 | getValue(value) { |
| 74 | if(typeof value == 'function' && value.length == 1) { |
| 75 | if(value.constructor.name == 'GeneratorFunction') { |
| 76 | const it = value(this) |
| 77 | const go = (result) => { |
| 78 | if (result.done) return result.value |
| 79 | return result.value.then((v) => { |
| 80 | return go(it.next(v)) |
| 81 | }, (error) => { |
| 82 | return go(it.throw(error)) |
| 83 | }) |
| 84 | } |
| 85 | return it |
| 86 | } else { |
| 87 | return value(this) |
| 88 | } |
| 89 | } else { |
| 90 | return value |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | reduce(key, load_reducer, init_state = {}) { |
| 95 | if(this._cache[key] == undefined) { |