Skip to content

Commit 9ba6bbf

Browse files
author
Roman Kuznietsov
committed
fix dox
1 parent daad457 commit 9ba6bbf

File tree

14 files changed

+85
-121
lines changed

14 files changed

+85
-121
lines changed

addon/adapters/base.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ import LFAdapter from 'ember-localforage-adapter/adapters/localforage';
99
import LFSerializer from 'ember-localforage-adapter/serializers/localforage';
1010
import isObjectEmpty from 'ember-data-offline/utils/is-object-empty';
1111
/**
12-
This is an example of usage of Online and Offline mixins.
13-
It simplifies setup proccess. By default it use RESTAdapter and LocalForageAdapter,
14-
but you can use your own adapters that you like.
12+
A base adapter, that can be used as-is or extended if necessary.
1513
1614
@class BaseAdapter
1715
@extends DS.RESTAdapter

addon/jobs/localforage.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ import Ember from 'ember';
66
import jobMixin from 'ember-data-offline/mixins/job';
77
import persistOffline from 'ember-data-offline/utils/persist-offline';
88
/**
9+
An implementation of a syncronization job for the Localforage storage.
10+
911
@class Localforage
1012
@extends Ember.Object
1113
@uses Job
1214
@constructor
1315
**/
1416
export default Ember.Object.extend(jobMixin, {
1517
/**
16-
Executes task. Before executiong you need to set the method, which should be executed, and the params for method.
18+
A method called by default to execute the job.
19+
The method to be called as well as it's arguments can be customized.
1720
@method task
1821
@return promise {Promise}
1922
**/
@@ -25,7 +28,7 @@ export default Ember.Object.extend(jobMixin, {
2528
},
2629

2730
/**
28-
Task for saving records offline after findAll operation.
31+
Saves the loaded records to the local storage.
2932
@method findAll
3033
@param store {DS.Store}
3134
@param typeClass {DS.Model}
@@ -34,7 +37,7 @@ export default Ember.Object.extend(jobMixin, {
3437
persistOffline(this.get('adapter'), store, typeClass, null, 'findAll');
3538
},
3639
/**
37-
Task for saving record offline after find operation.
40+
Saves the loaded record to the local storage.
3841
@method find
3942
@param store {DS.Store}
4043
@param typeClass {DS.Model}
@@ -45,7 +48,7 @@ export default Ember.Object.extend(jobMixin, {
4548
persistOffline(adapter, store, typeClass, id, "find");
4649
},
4750
/**
48-
Task for saving records offline after findQuery operation.
51+
Saves the loaded record to the local storage.
4952
@method findQuery
5053
@param store {DS.Store}
5154
@param typeClass {DS.Model}
@@ -58,7 +61,7 @@ export default Ember.Object.extend(jobMixin, {
5861
},
5962

6063
/**
61-
Task for saving records offline after findMany operation.
64+
Saves the loaded records to the local storage.
6265
@method findMany
6366
@param store {DS.Store}
6467
@param typeClass {DS.Model}
@@ -69,7 +72,7 @@ export default Ember.Object.extend(jobMixin, {
6972
persistOffline(adapter, store, typeClass, ids, 'findMany');
7073
},
7174
/**
72-
Task for saving record offline after createRecord operation.
75+
Saves the loaded record to the local storage.
7376
7477
@method createRecord
7578
@param store {DS.Store}
@@ -83,7 +86,7 @@ export default Ember.Object.extend(jobMixin, {
8386
});
8487
},
8588
/**
86-
Task for updating record offline after updateRecord operation.
89+
Updates the record in the local storage.
8790
8891
@method updateRecord
8992
@param store {DS.Store}
@@ -97,7 +100,7 @@ export default Ember.Object.extend(jobMixin, {
97100
});
98101
},
99102
/**
100-
Task for deleting record offline after deleteRecord operation.
103+
Deletes the record from the local storage.
101104
102105
@method deleteRecord
103106
@param store {DS.Store}

addon/jobs/rest.js

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@ import { persistOne } from 'ember-data-offline/utils/persist-offline';
88
import { eraseOne } from 'ember-data-offline/utils/erase-offline';
99
import extractTargetRecordFromPayload from 'ember-data-offline/utils/extract-online';
1010
/**
11-
Lightweight online job for pushing the data from online adapter to store and syncing offline data with the data from the store.
11+
A job that syncronizes the local storage with the backend.
1212
@class Rest
1313
@extends Ember.Object
1414
@uses Job
1515
@constructor
1616
**/
1717
export default Ember.Object.extend(jobMixin, {
1818
/**
19-
Executes task. Before executiong you need to set the method, which should be executed, and the params for method.
19+
A method called by default to execute the job.
20+
The method to be called as well as it's arguments can be customized.
2021
@method task
2122
@return promise {Promise}
2223
**/
@@ -27,9 +28,7 @@ export default Ember.Object.extend(jobMixin, {
2728
return this.get('adapter')[this.get('method')].apply(this.get('adapter'), this.get('params'));
2829
},
2930
/**
30-
Pushes the raw of data from an adapter's findAll method to the store and creates
31-
the offline job for syncing offline data with the data from the store.
32-
Returns a promise for the resulting payload.
31+
Saves the data received from the backend to the local storage.
3332
@method findAll
3433
@param store {DS.Store}
3534
@param typeClass {DS.Model}
@@ -53,9 +52,7 @@ export default Ember.Object.extend(jobMixin, {
5352
},
5453

5554
/**
56-
Pushes the record form an adapter's find method to the store and creates
57-
the offline job for syncing offline data with the data from the store.
58-
Returns a promise for the resulting payload.
55+
Saves the data received from the backend to the local storage.
5956
@method find
6057
@param store {DS.Store}
6158
@param typeClass {DS.Model}
@@ -81,9 +78,7 @@ export default Ember.Object.extend(jobMixin, {
8178
},
8279

8380
/**
84-
Pushes the raw of data form an adapter's find method to the store and creates
85-
the offline job for syncing offline data with the data from the store.
86-
Returns a promise for the resulting payload.
81+
Saves the data received from the backend to the local storage.
8782
@method findQuery
8883
@param store {DS.Store}
8984
@param type {DS.Model}
@@ -102,8 +97,7 @@ export default Ember.Object.extend(jobMixin, {
10297
return adapterResp;
10398
},
10499
/**
105-
Pushes the raw of data form an adapter's find method into the store and creates
106-
the offline job for syncing offline data with the data from the store.
100+
Saves the data received from the backend to the local storage.
107101
@method findMany
108102
@param store {DS.Store}
109103
@param typeClass {DS.Model}
@@ -120,9 +114,8 @@ export default Ember.Object.extend(jobMixin, {
120114
return adapterResp;
121115
},
122116
/**
123-
Pushes a newly created record into the store and creates
124-
the offline job for saving this record into offline storage.
125-
@method findMany
117+
Saves the data received from the backend to the local storage.
118+
@method createRecord
126119
@param store {DS.Store}
127120
@param type {DS.Model}
128121
@param snapshot {DS.Snapshot}
@@ -147,9 +140,8 @@ export default Ember.Object.extend(jobMixin, {
147140
.catch(apiHandler);
148141
},
149142
/**
150-
Calls the updateRecord method on adapter.
151-
Returns a promise for the resulting payload.
152-
@method findMany
143+
Saves the data received from the backend to the local storage.
144+
@method updateRecord
153145
@param store {DS.Store}
154146
@param type {DS.Model}
155147
@param snapshot {DS.Snapshot}
@@ -161,9 +153,8 @@ export default Ember.Object.extend(jobMixin, {
161153
return adapter.updateRecord(store, type, snapshot, fromJob);
162154
},
163155
/**
164-
Calls the deleteRecord method on adapter.
165-
Returns a promise for the resulting payload.
166-
@method findMany
156+
Removes the deleted record from the local storage.
157+
@method deleteRecord
167158
@param store {DS.Store}
168159
@param type {DS.Model}
169160
@param snapshot {DS.Snapshot}

addon/mixins/base.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const { Mixin, $, on, computed, get, isPresent } = Ember;
1515
**/
1616
export default Mixin.create({
1717
/**
18-
Shows if adapter is offline.
18+
Availability of the backend.
1919
@property isOffline
2020
@type {boolean}
2121
**/
@@ -33,15 +33,16 @@ export default Mixin.create({
3333
**/
3434
offlineJob: offlineJob,
3535
/**
36-
The period of time during which record is considered to be not expired.
36+
Record cache expiration time. After expiration the record will be requested again
37+
rather than fetched from local storage.
3738
@property recordTTL
3839
@type {Object}
3940
**/
4041
recordTTL: moment.duration(12, 'hours'),
4142
/**
4243
Used by adapter to get queue.
4344
44-
Returns the working queue from an adapter. If there is no queue in adapter then returns queue from passed store.
45+
Returns the syncronization job queue of an adapter or a store.
4546
@private
4647
@method _workingQueue
4748
@param store {DS.Store}
@@ -56,8 +57,8 @@ export default Mixin.create({
5657
},
5758

5859
/**
59-
Adds job to queue. If onDemandKey param was passed, then job will be stored as 'onDemand'
60-
and will be processed on demand.
60+
Adds a job to the queue. If 'onDemandKey' param was passed, the job will be
61+
processed on-demand.
6162
6263
@method addToQueue
6364
@param job {Job} job to add to queue.
@@ -69,10 +70,8 @@ export default Mixin.create({
6970
},
7071

7172
/**
72-
Used by classes which use this class.
73-
74-
Creates the online job and addes it to queue. If onDemandKey param was passed, then job will be stored as 'onDemand'
75-
and will be processed on demand.
73+
Creates and adds an online job to the queue. If 'onDemandKey' param was passed, the job will be
74+
processed on-demand.
7675
7776
@method createOnlineJob
7877
@param method {String} the name of method which will be runned by job.
@@ -90,10 +89,8 @@ export default Mixin.create({
9089
this.addToQueue(job, store, onDemandKey);
9190
},
9291
/**
93-
Used by classes which use this class.
94-
95-
Creates the offline job and addes it to queue. If onDemandKey param was passed, then job will be stored as 'onDemand'
96-
and will be processed on demand.
92+
Creates and adds an offline job to the queue. If 'onDemandKey' param was passed, the job will be
93+
processed on-demand.
9794
9895
@method createOfflineJob
9996
@param method {String} the name of method which will be runned by job.

addon/mixins/job.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import Ember from 'ember';
55
const { computed, RSVP } = Ember;
66

77
/**
8-
Base class for creating lightweight jobs.
8+
An abstract job.
99
10-
Job is an abstract class and is not meant to be used directly. The following classes extend Job:
10+
Examples:
1111
{{#crossLink "Localforage"}}{{/crossLink}}
1212
{{#crossLink "Rest"}}{{/crossLink}}
1313
@@ -23,7 +23,7 @@ export default Ember.Mixin.create({
2323
retryCount: 0,
2424

2525
/**
26-
Shows if there are retry attempts.
26+
Shows if there are retry attempts left.
2727
@property needRetry
2828
@type {boolean}
2929
**/
@@ -38,7 +38,7 @@ export default Ember.Mixin.create({
3838
},
3939

4040
/**
41-
Called by the Queue to perform the job.
41+
Called to perform the job.
4242
@method perform
4343
@return {Ember.Promise}
4444
**/

addon/mixins/offline.js

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { isExpiredOne, isExpiredMany, isExpiredAll } from 'ember-data-offline/ut
99
import { updateMeta } from 'ember-data-offline/utils/meta';
1010

1111
/**
12-
Ofline mixin redefines all adapter methods for finding, creation, deletion to make request to offline storage.
12+
Offline mixin redefines all adapter persistance methods to make request to offline storage.
1313
1414
@class Offline
1515
@extends Ember.Mixin
@@ -31,8 +31,8 @@ export default Ember.Mixin.create(baseMixin, {
3131
},
3232

3333
/**
34-
Returns the metadata for a given. Returned metadata consists information about
35-
last fetched and last updated time.
34+
Returns the metadata for a given model. Returned metadata contains information about
35+
latest fetch and update times.
3636
3737
@method metadataForType
3838
@param typeClass {DS.Model}
@@ -45,9 +45,10 @@ export default Ember.Mixin.create(baseMixin, {
4545
},
4646

4747
/**
48-
Overrides the method of an extended adapter (offline). Fetches a JSON array for all of the records for a given type
49-
from offline adapter. If fetched records are expired then tries to create online job of fetching the records
50-
from online adapter and persisting them offline. Returns a promise for the resulting payload.
48+
Overrides the method of an extended adapter (offline). Fetches a JSON array
49+
for all of the records for a given type from offline adapter. If fetched
50+
records are expired, it tries to create an online job to fetch the records
51+
from the online adapter and save them locally.
5152
5253
@method findAll
5354
@param store {DS.Store}
@@ -73,9 +74,9 @@ export default Ember.Mixin.create(baseMixin, {
7374
},
7475

7576
/**
76-
Overrides the method of an extended adapter (offline). Fetches a JSON for a given type and ID
77-
from offline adapter. If fetched record is expired then tries to create online job of fetching the record
78-
from online adapter and persisting it offline. Returns a promise for the resulting payload.
77+
Overrides the method of an extended adapter (offline). Fetches a JSON array for all of the records for a given type
78+
from offline adapter. If fetched expired records and then tries to create an online job to fetch the records
79+
from the online adapter and save them locally.
7980
@method find
8081
@param store {DS.Store}
8182
@param typeClass {DS.Model}
@@ -102,9 +103,9 @@ export default Ember.Mixin.create(baseMixin, {
102103
},
103104

104105
/**
105-
Overrides the method of an extended adapter (offline). Fetches a JSON array for the records that match a particular query
106-
from offline adapter. If fetched records are expired then tries to create online job of fetching the records
107-
from online adapter and persisting them offline. Returns a promise for the resulting payload.
106+
Overrides the method of an extended adapter (offline). Fetches a JSON array for all of the records for a given type
107+
from offline adapter. If fetched expired records and then tries to create an online job to fetch the records
108+
from the online adapter and save them locally.
108109
109110
@method query
110111
@param store {DS.Store}
@@ -132,9 +133,9 @@ export default Ember.Mixin.create(baseMixin, {
132133
},
133134

134135
/**
135-
Overrides the method of an extended adapter (offline). Fetches a JSON array for a given type and IDs
136-
from offline adapter. If fetched records are expired then tries to create online job of fetching the records
137-
from online adapter and persisting them offline. Returns a promise for the resulting payload.
136+
Overrides the method of an extended adapter (offline). Fetches a JSON array for all of the records for a given type
137+
from offline adapter. If fetched expired records and then tries to create an online job to fetch the records
138+
from the online adapter and save them locally.
138139
139140
@method findMany
140141
@param store {DS.Store}
@@ -165,9 +166,8 @@ export default Ember.Mixin.create(baseMixin, {
165166
},
166167

167168
/**
168-
Called when a newly created record is saved via the `save` method on a model record instance.
169-
If this method was called from Queue(fromJob) then it would create an online job for creation record.
170-
Calls the implementation method of parrent offline adapter.
169+
Overrides the method of an extended adapter (offline).
170+
If tries to create an online job to create the record and save it locally.
171171
@method createRecord
172172
@param store {DS.Store}
173173
@param type {DS.Model}
@@ -190,11 +190,8 @@ export default Ember.Mixin.create(baseMixin, {
190190
return this._super.apply(this, [store, type, snapshot]);
191191
},
192192
/**
193-
Called when an existing record is saved
194-
via the `save` method on a model record instance.
195-
196-
If this method was called from Queue(fromJob) then it would create an online job for updating record.
197-
Calls the implementation method of parrent offline adapter.
193+
Overrides the method of an extended adapter (offline).
194+
If tries to create an online job to update the record and save it locally.
198195
@method updateRecord
199196
@param store {DS.Store}
200197
@param type {DS.Model}
@@ -211,9 +208,8 @@ export default Ember.Mixin.create(baseMixin, {
211208
return this._super.apply(this, [store, type, snapshot]);
212209
},
213210
/**
214-
Called when a record is deleted.
215-
If this method was called from Queue(fromJob) then it would create an online job for deletion record.
216-
Calls the implementation method of parrent offline adapter.
211+
Overrides the method of an extended adapter (offline).
212+
If tries to create an online job to delete the record and remove it locally.
217213
@method deleteRecord
218214
@param store {DS.Store}
219215
@param type {DS.Model}

0 commit comments

Comments
 (0)