Skip to content

Commit

Permalink
chore: refactor promiseRecord
Browse files Browse the repository at this point in the history
  • Loading branch information
runspired committed Jun 17, 2019
1 parent 48dd812 commit 5fbe91b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
11 changes: 1 addition & 10 deletions packages/store/addon/-private/system/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,14 @@ import RecordArrayManager from './record-array-manager';
import InternalModel from './model/internal-model';
import RecordDataDefault from './model/record-data';
import edBackburner from './backburner';

import promiseRecord from '../utils/promise-record';
const badIdFormatAssertion = '`id` passed to `findRecord()` has to be non-empty string or number';
const emberRun = emberRunLoop.backburner;

const { ENV } = Ember;

let globalClientIdCounter = 1;

//Get the materialized model from the internalModel/promise that returns
//an internal model and return it in a promiseObject. Useful for returning
//from find methods
function promiseRecord(internalModelPromise, label) {
let toReturn = internalModelPromise.then(internalModel => internalModel.getRecord());

return promiseObject(toReturn, label);
}

// Implementors Note:
//
// The variables in this file are consistently named according to the following
Expand Down
18 changes: 18 additions & 0 deletions packages/store/addon/-private/utils/promise-record.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import InternalModel from '../system/model/internal-model';
import { promiseObject } from '../system/promise-proxies';

/**
* Get the materialized model from the internalModel/promise
* that returns an internal model and return it in a promiseObject.
*
* Useful for returning from find methods
*
* @private
* @param internalModelPromise
* @param label
*/
export default function promiseRecord(internalModelPromise: Promise<InternalModel>, label: string) {
let toReturn = internalModelPromise.then(internalModel => internalModel.getRecord());

return promiseObject(toReturn, label);
}

0 comments on commit 5fbe91b

Please sign in to comment.