Skip to content

Commit 54e59fb

Browse files
committed
inline doc improvements
1 parent 67b9cd0 commit 54e59fb

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/EmbeddedCollection.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// import LoadingStoreCollection from './LoadingStoreCollection'
21
import { EmbeddedCollectionMeta } from './interfaces/EmbeddedCollection'
32
import { Link } from './interfaces/StoreData'
43

@@ -26,9 +25,7 @@ class EmbeddedCollection implements EmbeddedCollectionMeta {
2625
* @param items array of items, which can be mixed primitive values and entity references
2726
* @param reloadUri URI of the entity containing the embedded collection (for reloading)
2827
* @param reloadProperty property in the containing entity under which the embedded collection is saved
29-
* @param apiActions dependency injection of API actions
30-
* @param config dependency injection of config object
31-
* @param loadParent a promise that will resolve when the parent entity has finished (re-)loading
28+
* @param loadCollection a promise that will resolve when the parent entity has finished (re-)loading
3229
*/
3330
constructor (items: Array<Link>, reloadUri: string, reloadProperty: string, loadCollection: Promise<EmbeddedCollectionMeta> | null = null) {
3431
this._storeData = {

src/HasItems.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ function HasItems<TBase extends HasStoreData> (Base: TBase, apiActions: ApiActio
3636
}
3737

3838
/**
39-
* Returns true if any of the items within 'array' is not yet known to the API (meaning it has never been loaded)
40-
*/
39+
* Returns true if any of the items within 'array' is not yet known to the API (meaning it has never been loaded)
40+
*/
4141
function containsUnknownEntityReference (array: Array<Link>): boolean {
4242
return array.some(entry => isEntityReference(entry) && apiActions.isUnknown(entry.href))
4343
}
@@ -71,20 +71,20 @@ function HasItems<TBase extends HasStoreData> (Base: TBase, apiActions: ApiActio
7171
*/
7272
_itemLoader (array: Array<Link>) : Promise<Collection> {
7373
if (!containsUnknownEntityReference(array)) {
74-
return Promise.resolve(this as unknown as Collection)
74+
return Promise.resolve(this as unknown as Collection) // we know that this object must be of type Collection
7575
}
7676

7777
// eager loading of 'fetchAllUri' (e.g. parent for embedded collections)
7878
if (config.avoidNPlusOneRequests && reloadUri) {
79-
return apiActions.reload({ _meta: { reload: { uri: reloadUri || '', property: reloadProperty || '' } } }) as Promise<Collection>
79+
return apiActions.reload({ _meta: { reload: { uri: reloadUri || '', property: reloadProperty || '' } } }) as Promise<Collection> // we know that reload resolves to a type Collection
8080

8181
// no eager loading: replace each reference (Link) with a StoreValue (Resource)
8282
} else {
8383
const arrayWithReplacedReferences = replaceEntityReferences(array)
8484

8585
return Promise.all(
8686
arrayWithReplacedReferences.map(entry => entry._meta.load)
87-
).then(() => this as unknown as Collection)
87+
).then(() => this as unknown as Collection) // we know that this object must be of type Collection
8888
}
8989
}
9090

0 commit comments

Comments
 (0)