Last active
April 17, 2023 04:49
-
-
Save pgengler/83ed7772daf1e60dc48f216a6674b5b6 to your computer and use it in GitHub Desktop.
ember-data unload issue 3.28
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
import Component from '@glimmer/component'; | |
import { action } from '@ember/object'; | |
import { inject as service } from '@ember/service'; | |
export default class extends Component { | |
@service router; | |
@action async delete() { | |
const a = this.args.a; | |
const b = a.b; | |
await a.destroyRecord(); | |
this.router.transitionTo('b', b.get('id')); | |
} | |
} |
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
import Controller from '@ember/controller'; | |
export default class ApplicationController extends Controller { | |
appName = 'Ember Twiddle'; | |
} |
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
import Model, { belongsTo } from '@ember-data/model'; | |
export default class extends Model { | |
@belongsTo b; | |
} |
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
import Model, { attr, hasMany } from '@ember-data/model'; | |
export default class extends Model { | |
@hasMany a; | |
} |
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
import EmberRouter from '@ember/routing/router'; | |
import config from './config/environment'; | |
const Router = EmberRouter.extend({ | |
location: 'none', | |
rootURL: config.rootURL | |
}); | |
Router.map(function() { | |
this.route('a', { path: '/a/:id' }); | |
this.route('b', { path: '/:id' }); | |
}); | |
export default Router; |
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
import Route from '@ember/routing/route'; | |
import { inject as service } from '@ember/service'; | |
export default class ARoute extends Route { | |
@service store; | |
model({ id }) { | |
return this.store.peekRecord('a', id); | |
} | |
} |
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
import Route from '@ember/routing/route'; | |
import { inject as service } from '@ember/service'; | |
export default class extends Route { | |
@service store; | |
beforeModel() { | |
const b = this.store.createRecord('b', { id: 1 }); | |
this.store.createRecord('a', { id: 1, b, title: 'Foo' }); | |
this.store.createRecord('a', { id: 2, b, title: 'Bar' }); | |
this.store.createRecord('a', { id: 3, b, title: 'Baz' }); | |
} | |
} |
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
import Route from '@ember/routing/route'; | |
import { inject as service } from '@ember/service'; | |
export default class BRoute extends Route { | |
@service store; | |
model({ id }) { | |
return this.store.peekRecord('b', id); | |
} | |
} |
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
import Route from '@ember/routing/route'; | |
import { inject as service } from '@ember/service'; | |
export default class IndexRoute extends Route { | |
@service router; | |
@service store; | |
beforeModel() { | |
const bs = this.store.peekAll('b'); | |
this.router.transitionTo('b', bs.firstObject.id); | |
} | |
} |
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
{ | |
"version": "0.17.1", | |
"EmberENV": { | |
"FEATURES": {}, | |
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false, | |
"_APPLICATION_TEMPLATE_WRAPPER": true, | |
"_JQUERY_INTEGRATION": true | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js", | |
"ember": "3.18.1", | |
"ember-template-compiler": "3.18.1", | |
"ember-testing": "3.18.1" | |
}, | |
"addons": { | |
"@glimmer/component": "1.0.0", | |
"ember-data": "3.28.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment