Created
March 15, 2021 18:51
-
-
Save kmccullough/0938e67614dd590461fefc5973df3483 to your computer and use it in GitHub Desktop.
ObjectProxyFalsey
This file contains hidden or 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 { inject } from '@ember/service'; | |
| //import { cached } from '@glimmer/tracking'; | |
| export default class extends Component { | |
| @inject pagesService; | |
| //@cached | |
| get page() { | |
| const { location } = this.args; | |
| console.log('page'); | |
| return location && this.pagesService.fetch(location); | |
| } | |
| } |
This file contains hidden or 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 hidden or 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 { helper } from '@ember/component/helper'; | |
| const TRUE = ' '; | |
| const FALSE = ''; | |
| export default helper(function or(values/*, hash*/) { | |
| let v = TRUE; | |
| const result = values.some(p => v = p) ? v : FALSE; | |
| console.log('or', !!result, result); | |
| return result; | |
| }); |
This file contains hidden or 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 Service from '@ember/service'; | |
| import ObjectProxy from '@ember/object/proxy'; | |
| export default Service.extend({ | |
| /** | |
| * @param {string} location | |
| * @return {ObjectProxy} | |
| */ | |
| fetch(location) { | |
| //const response = this.store.query('ui-page', { | |
| // [`filter[some-field]`]: location | |
| //}); | |
| // Some mock behavior to simulate the above actual query | |
| if (!this.result) { | |
| const response = new Promise(resolve => setTimeout(() => { | |
| console.log('resolved'); | |
| resolve(); | |
| }, 3000)); | |
| response.firstObject = null; | |
| console.log('fetch'); | |
| this.result = ObjectProxy.create(); | |
| response.then(() => { | |
| this.result.set('content', response.firstObject); | |
| }); | |
| } | |
| return this.result; | |
| }, | |
| }); |
This file contains hidden or 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" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment