-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removing detect function (and dependence on model package) in favor o…
…f watchModelTypes
- Loading branch information
pliljegr
committed
Oct 2, 2019
1 parent
f5e0e51
commit afd687b
Showing
5 changed files
with
109 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Model, { attr, belongsTo, hasMany } from '@ember-data/model'; | ||
|
||
export default class extends Model { | ||
@attr name; | ||
@belongsTo('foo', { async: false }) parent; | ||
@hasMany('foo', { async: false }) children; | ||
} |
15 changes: 14 additions & 1 deletion
15
packages/-ember-data/tests/dummy/app/routes/application/route.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
export default Route.extend({}); | ||
export default Route.extend({ | ||
model() { | ||
// adding a model to the store to enable manually testing the debug-adapter | ||
return this.store.push({ | ||
data: { | ||
id: 1, | ||
type: 'foo', | ||
attributes: { | ||
name: 'taco' | ||
} | ||
} | ||
}) | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export const StoreTypesMap = new WeakMap(); | ||
|
||
function setupDataAdapter(application) { | ||
const store = application.lookup('service:store'); | ||
const typesMap = new Map(); | ||
// its possible the app has more than one store, so this works on the 'main' store | ||
StoreTypesMap.set(store, typesMap); | ||
|
||
const __createRecordData = store._createRecordData; | ||
// override _createRecordData to add the known models to the typesMap | ||
store._createRecordData = function(identifier) { | ||
if (!typesMap.has(identifier.type)) { | ||
typesMap.set(identifier.type, false); | ||
} | ||
return __createRecordData.call(store, identifier); | ||
}; | ||
} | ||
|
||
export default { | ||
name: '@ember-data/data-adapter', | ||
initialize: setupDataAdapter, | ||
}; |
1 change: 1 addition & 0 deletions
1
packages/debug/app/instance-initializers/ember-data-data-adapter.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from '@ember-data/debug/setup'; |