Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ember Runtime Functions not accessible in fastboot mode #251

Open
neeraj-joshi01 opened this issue Aug 5, 2016 · 6 comments
Open

Ember Runtime Functions not accessible in fastboot mode #251

neeraj-joshi01 opened this issue Aug 5, 2016 · 6 comments

Comments

@neeraj-joshi01
Copy link

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"

@danmcclain
Copy link
Member

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?

@neeraj-joshi01
Copy link
Author

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.

@danmcclain
Copy link
Member

Could you create an example project the exhibits this? The workaround for now would be to use Ember.EnumberableUtils.filterBy for now

@igorT
Copy link

igorT commented Sep 16, 2016

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

igorT added a commit to igorT/ember-power-select that referenced this issue Sep 16, 2016
igorT added a commit to igorT/ember-power-select that referenced this issue Sep 16, 2016
igorT added a commit to igorT/ember-power-select that referenced this issue Sep 16, 2016
@sevab
Copy link

sevab commented Dec 13, 2016

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.

@nag5000
Copy link

nag5000 commented Mar 15, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants