-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
366 lines (298 loc) · 11.4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Introducing Ember.js Persistence Foundation</title>
<meta name="description" content="A framework for keeping your Ember.js apps in sync.">
<meta name="author" content="Gordon L. Hempton">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="css/reveal.min.css">
<link rel="stylesheet" href="css/theme/default.css" id="theme">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- If the query includes 'print-pdf', use the PDF print sheet -->
<script>
document.write( '<link rel="stylesheet" href="css/print/' + ( window.location.search.match( /print-pdf/gi ) ? 'pdf' : 'paper' ) + '.css" type="text/css" media="print">' );
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h1>EPF</h1>
<h3>A framework for keeping your Ember.js apps in sync.</h3>
<p>
<small>Created by <a href="http://codebrief.com">Gordon L. Hempton</a> / <a href="http://twitter.com/ghempton">@ghempton</a> / <a href="https://grouptalent.com">GroupTalent</a> / <a href="epf.io">epf.io</a></small>
</p>
</section>
<section>
<h2>Why Another Framework?</h2>
<ul>
<li><a href="https://github.com/emberjs/data">Ember Data</a></li>
<li><a href="https://github.com/endlessinc/ember-restless">Ember Restless</a></li>
<li><a href="https://github.com/zendesk/ember-resource.git">Ember Resource</a></li>
<li><a href="https://github.com/ebryn/ember-model">Ember Model</a></li>
<li class="fragment"><a href="https://github.com/GroupTalent/epf">EPF</a></li>
</ul>
</section>
<section>
<h2>History</h2>
<ul>
<li>Migrated from Rails to Ember w/ Ember Data</li>
<li><a href="https://github.com/emberjs/data/commit/740a69ef70bdaa1ae4412b3d73b4f01169b4d51d">First PR</a> made two years ago</li>
<li>Been through every single revision of Ember Data</li>
</ul>
</section>
<section>
<h2>Ember Data - The Good</h2>
<ul>
<li>Loading data</li>
<li>Serialization</li>
<li>Sideloading</li>
<li>Relationships</li>
<li>Right level of abstraction</li>
</ul>
</section>
<section>
<h2>Ember Data - The Bad</h2>
<ul>
<li>Transactions</li>
<li>Data is "locked" while being committed</li>
<li>Limited error handling</li>
<li>Corner cases</li>
<li>Live on a fork</li>
</ul>
</section>
<section>
<h2>Needed to move off of Ember Data.</h2>
</section>
<section>
<h2>Other Solutions</h2>
<ul>
<li>Too lightweight</li>
<li>Missing features</li>
<li>Hard to migrate from ED</li>
</ul>
</section>
<section>
<img src="img/jonah.jpg">
</section>
<section>
<h2>Time to build a new persistence framework.</h2>
<h3 class="fragment">EPF was born</h3>
</section>
<section>
<h2>Observations</h2>
<ul>
<li>Reading data is easy<sup>*</sup></li>
<li>Modifying data is difficult (esp. relationships)</li>
<li>Always expect new data</li>
</ul>
</section>
<section>
<h2>Designing EPF</h2>
<ul>
<li>Non-blocking</li>
<li>Focus on synchronization</li>
<li>Correctness first, performance second</li>
<li>Straightforward migration from Ember Data</li>
<li>Re-think primitives (e.g. transactions)</li>
</ul>
</section>
<section>
<h2>EPF Today</h2>
<ul>
<li>Everything shown implemented</li>
<li>Used in production at <a href="https://grouptalent.com">GroupTalent</a></li>
<li>~35 inter-related models</li>
<li>Not perfect</li>
</ul>
</section>
<section>
<h1>API</h1>
</section>
<section>
<h2>Setup</h2>
<pre><code data-trim contenteditable class="javascript">
App.Adapter = Ep.RestAdapter.extend({
namespace: 'api' // optionally set a prefix for all urls
});
</code></pre>
</section>
<section>
<h2>Defining Models</h2>
<pre><code data-trim contenteditable class="javascript">
App.Group = Ep.Model.extend({
name: Ep.attr('string'),
users: Ep.hasMany(App.User)
});
App.User = Ep.Model.extend({
name: Ep.attr('string'),
group: Ep.belongsTo(App.Group)
});
</code></pre>
</section>
<section>
<h2>Loading Models</h2>
<pre><code data-trim contenteditable class="javascript">
session.load(App.User, 1);
session.load('user', 1); // string version
session.load('user', 1).then(function(user) {
// user will be loaded
});
</code></pre>
</section>
<section>
<h2>Creating Models</h2>
<pre><code data-trim contenteditable class="javascript">
session.create(App.User, {name: 'herp'});
session.create('user', {name: 'herp'}); // alternative string version
session.flush().then(function() {
// changes will have been persisted
});
</code></pre>
</section>
<section>
<h2>Updating Models</h2>
<pre><code data-trim contenteditable class="javascript">
user.set('name', 'embereno');
session.flush().then(function() {
// changes will have been persisted
});
// updates can happen while a flush is pending
user.set('name', 'kris');
</code></pre>
</section>
<section>
<h2>Relationships</h2>
<pre><code data-trim contenteditable class="javascript">
var group = session.create('group', {name: 'emberenos'});
user.set('group', group);
// inverse relationships automatically updated
group.get('users'); // [user]
</code></pre>
</section>
<section>
<h2>Putting it all together</h2>
<pre><code data-trim contenteditable class="javascript">
var group = session.create('group', {name: 'emberenos'});
var user = session.create('user', {name: 'dave'});
user.set('group', group);
group.get('users').pushObject(existingUser);
session.flush().then(function() {
// all changes will be persisted
});
</code></pre>
</section>
<section>
<h2>Isolating Changes</h2>
<pre><code data-trim contenteditable class="javascript">
var user = session.load(App.User, 1);
// this create a "fork" of the session
var childSession = session.newSession();
// this user will be a separate instance from `user`
var childUser = childSession.load(App.User, 1);
user === childUser; // false, they are separate instances
user.isEqual(childUser); // true, key based comparison
childUser.name = 'derp'; // this will not affect `user`
// flush changes immediately to the parent session and server
childSession.flush();
</code></pre>
</section>
<section>
<h2>Merging Changes - Under the Hood</h2>
<pre><code data-trim contenteditable class="javascript">
$.getJSON('/users/1', function(data) {
var user = App.User.create(data);
session.merge(user);
});
var socket = io.connect('http://localhost');
socket.on('user', function (data) {
var user = App.User.create(data);
session.merge(user);
});
</code></pre>
</section>
<section>
<h2>Naive Sync</h2>
<img src="img/naive.svg" class="transparent">
</section>
<section>
<h2>What if...</h2>
<ul>
<li>Updates happen while request is in transit?</li>
<li>Error handling?
</li>
</section>
<section>
<h2>EPF Sync</h2>
<img src="img/200.svg" class="transparent">
</section>
<section>
<h2>EPF Sync</h2>
<img src="img/412.svg" class="transparent">
</section>
<section>
<h2>Roadmap</h2>
<ul>
<li>Implement low hanging features</li>
<li>Cleanup some internals (better perf)</li>
<li>Improved collections (pagination, etc.)</li>
<li>Socket Adapter</li>
<li>Starter kit</li>
</ul>
</section>
<section>
<h2>Future</h2>
<p>REST vs. Sockets</p>
<p>Realtime?</p>
</section>
<section>
<h2>Differential Synchronization</h2>
<img src="img/diff3a.gif">
<p><small>by <a href="http://neil.fraser.name/writing/sync/">Neil Fraser</a></small></p>
</section>
<section>
<h2>That is all.</h2>
<p>
<small><a href="http://codebrief.com">Gordon L. Hempton</a> / <a href="http://twitter.com/ghempton">@ghempton</a> / <a href="https://grouptalent.com">GroupTalent</a> / <a href="epf.io">epf.io</a></small>
</p>
<h3>Thanks</h3>
<p><small>Tom Dale, Yehuda Katz, Stefan Penner, and all the ED contributors</small></p>
<p><small>Ray Bunnage and heartsentwined for early adoption</small></p>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.min.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
theme: Reveal.getQueryHash().theme || 'epf', // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'default', // default/cube/page/concave/zoom/linear/fade/none
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
{ src: 'plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }
// { src: 'plugin/search/search.js', async: true, condition: function() { return !!document.body.classList; } }
// { src: 'plugin/remotes/remotes.js', async: true, condition: function() { return !!document.body.classList; } }
]
});
</script>
</body>
</html>