The Future
When last we saw our HipsterModel, we had replaced direct Ajax calls with a data synchronization layer that was cleverly named HipsterSync. In the save method, it looks like this:
| class HipsterModel { |
| // ... |
| save({callback}) { |
| HipsterSync.send('post', this, options: { |
| 'onLoad': (attrs) { |
| attributes = attrs; |
| if (callback != null) callback(this); |
| } |
| }); |
| } |
| } |
There are at least three issues with this approach. First, we are invoking send with too many arguments—we need to indicate that this is a “post,” and this is necessary so that HipsterSync knows what to sync—but the options parameter describes only a side effect and is not needed in order to perform the main execution thread. Second, the readability ...
Get Dart 1 for Everyone now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.