| 1291 | const id = metaData.id; |
| 1292 | const bound = metaData.bound; |
| 1293 | let action = function (): Promise<T> { |
| 1294 | // $FlowFixMe[method-unbinding] |
| 1295 | const args = Array.prototype.slice.call(arguments); |
| 1296 | const p = bound; |
| 1297 | if (!p) { |
| 1298 | return callServer(id, args); |
| 1299 | } |
| 1300 | if (p.status === 'fulfilled') { |
| 1301 | const boundArgs = p.value; |
| 1302 | return callServer(id, boundArgs.concat(args)); |
| 1303 | } |
| 1304 | // Since this is a fake Promise whose .then doesn't chain, we have to wrap it. |
| 1305 | // TODO: Remove the wrapper once that's fixed. |
| 1306 | return ((Promise.resolve(p): any): Promise<Array<any>>).then( |
| 1307 | function (boundArgs) { |
| 1308 | return callServer(id, boundArgs.concat(args)); |
| 1309 | }, |
| 1310 | ); |
| 1311 | }; |
| 1312 | if (__DEV__) { |
| 1313 | const location = metaData.location; |
| 1314 | if (location) { |