(prop, mapping, startedAt)
| 289 | } |
| 290 | |
| 291 | createPromise(prop, mapping, startedAt) { |
| 292 | const meta = mapping.meta |
| 293 | const initPS = this.createInitialPromiseState(prop, mapping) |
| 294 | const onFulfillment = this.createPromiseStateOnFulfillment(prop, mapping, startedAt) |
| 295 | const onRejection = this.createPromiseStateOnRejection(prop, mapping, startedAt) |
| 296 | if (mapping.hasOwnProperty('value')) { |
| 297 | let value = mapping.value |
| 298 | if (typeof value === 'function') { |
| 299 | value = value() |
| 300 | } |
| 301 | |
| 302 | if (value && typeof value.then === 'function') { |
| 303 | this.setAtomicState(prop, startedAt, mapping, initPS(meta)) |
| 304 | return value.then(onFulfillment(meta), onRejection(meta)) |
| 305 | } else { |
| 306 | return onFulfillment(meta)(value) |
| 307 | } |
| 308 | } else { |
| 309 | const request = mapping.buildRequest(mapping) |
| 310 | meta.request = request |
| 311 | this.setAtomicState(prop, startedAt, mapping, initPS(meta)) |
| 312 | |
| 313 | const fetched = mapping.fetch(request) |
| 314 | return fetched |
| 315 | .then(response => { |
| 316 | meta.response = response |
| 317 | meta.component = this.refs.wrappedInstance |
| 318 | |
| 319 | return response |
| 320 | }) |
| 321 | .then(mapping.handleResponse) |
| 322 | .then(onFulfillment(meta), onRejection(meta)) |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | createInitialPromiseState(prop, mapping) { |
| 327 | return (meta) => { |
no test coverage detected