-
-
Save riklomas/e16f3cbcf957ad9767a23ba205d45d11 to your computer and use it in GitHub Desktop.
testing on 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 Controller from '@ember/controller'; | |
import { reads } from '@ember/object/computed'; | |
export default Controller.extend({ | |
children: reads('model'), | |
actions: { | |
clickChild(child) { | |
child.parent.then(parent => { | |
console.log(parent.name); | |
}); | |
} | |
} | |
}); |
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
export default function() { | |
this.resource('message-thread'); | |
this.resource('message-message'); | |
this.resource('user'); | |
} |
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 { Factory } from 'ember-cli-mirage'; | |
export default Factory.extend({ | |
name(i) { return `Message message-${i}`; } | |
}); |
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 { Factory } from 'ember-cli-mirage'; | |
export default Factory.extend({ | |
name(i) { return `Thread-${i}`; } | |
}); |
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 { Factory } from 'ember-cli-mirage'; | |
export default Factory.extend({ | |
name(i) { return `User-${i}`; } | |
}); |
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
export default function(server) { | |
let messageThread = server.create('message-thread'); | |
let messageThread2 = server.create('message-thread'); | |
let user = server.create('user'); | |
server.createList('message-message', 10, { messageThread, user }); | |
server.createList('message-message', 10, { messageThread: messageThread2, user }); | |
} |
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 { JSONAPISerializer } from 'ember-cli-mirage'; | |
export default JSONAPISerializer.extend({ | |
alwaysIncludeLinkageData: true, | |
}); |
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 DS from 'ember-data' | |
const {Model, attr, hasMany, belongsTo} = DS | |
export default DS.Model.extend({ | |
messageThread: belongsTo('message-thread', { async: true }), | |
user: belongsTo("user", {async: true}), | |
name: attr(), | |
}); |
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 DS from 'ember-data' | |
const {Model, attr, hasMany, belongsTo} = DS | |
export default DS.Model.extend({ | |
messageMessages: hasMany({ async: true }), | |
name: attr(), | |
}); |
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 DS from 'ember-data' | |
const {Model, attr, hasMany} = DS | |
export default Model.extend({ | |
name: attr(), | |
messageMessages: hasMany(), | |
}); |
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'; | |
export default Route.extend({ | |
model() { | |
return this.store.findAll('message-thread'); | |
} | |
}); |
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.15.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"ENV": { | |
"ember-cli-mirage": { | |
"enabled": true | |
} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.9.0", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3" | |
}, | |
"addons": { | |
"ember-data": "3.11.0", | |
"ember-cli-mirage": "0.4.6" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment