ember-cli-fastboot
ember-cli-fastboot copied to clipboard
Ember Runtime Functions not accessible in fastboot mode
Using ember-cli-fastboot with ember v2.4.0, and i am trying to access filterBy method on array and i get the error "arrayName.filterBy is not defined"
This is a known issue. The problem lies around prototype extensions and the fact that objects can be created in contexts outside of the Ember context (due to the way require
works with npm). We should have had an issue open for tracking, thank you!
To guess: You have an array that is coming from najax via or something similar?
I have a simple array declared as var filters = [{key: 'Procedure'}] and then I am using filterBy on this array which is not accessible till ember-runtime module gets invoked.
Could you create an example project the exhibits this? The workaround for now would be to use Ember.EnumberableUtils.filterBy
for now
It would be great if Ember.A
worked while this was broken. Currently it believes that Prototype Extensions work, so the common workaround of wrapping things in an Ember.A
fails. I don't think objectAt
is available as a util for example
Having a similar issue when rendering in fastboot mode in Ember 2.10.0.
When trying to findBy
on an array that's an attribute of a DS.Model
record:
record.get('categories').findBy('token', params.category)
a TypeError is thrown:
Unknown Error: TypeError: record.get(...).findBy is not a function
Wrapping a DS.Model
array with Ember.A()
doesn't solve anything. However, a manually-declared array inherits Ember.Array
methods by default and work as expected.
Is there a workaround for this?
My temp solution is to either implement findBy
functionality manually, or do a hard conversion of the DS.Model
array to an ember array with const emberArr = JSON.parse(JSON.stringify(record.get('categories')))
and run findBy
on it.
Having a similar issue when using get(response, 'comments.firstObject')
, where response
is a result of await fetch -> await response.json()
and response.comments
is an array.
- browser:
get(response, 'comments.firstObject') // ok
- fastboot:
get(response, 'comments.firstObject') // not ok - undefined
- fastboot:
get(response, 'comments.0') // ok