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

Integration with ember-cli #8

Closed
tute opened this issue Jul 2, 2014 · 11 comments
Closed

Integration with ember-cli #8

tute opened this issue Jul 2, 2014 · 11 comments

Comments

@tute
Copy link
Contributor

tute commented Jul 2, 2014

For integrating into an ember-cli project that used data, I'm doing:

  1. Remove ember-data altogether (I suspect it was the source of the The initializer 'injectStore' has already been registered error). In my case it was tied to the models, DS.RESTAdapter, package and bower.json, and a custom app/transforms/array.js.

  2. Add to bower.json (got this snippet from https://github.com/opsb/ember-orbit-todos/blob/master/bower.json):

    "orbit.js": "~0.2",
    "ember-orbit-development": "https://lytbulb-vendor.s3.amazonaws.com/ember-orbit/347f1d3/ember-orbit.js",
    "ember-orbit-production": "https://lytbulb-vendor.s3.amazonaws.com/ember-orbit/347f1d3/ember-orbit.min.js"
    

    This is related with Build npm package #7, about having an npm package for ember-orbit (that could require orbit.js itself).

  3. Add app/initializers/orbit-store.js, similar to https://github.com/orbitjs/ember-orbit#initialization. Now stuck in there, with errors like ReferenceError: Orbit is not defined.

Are there blog posts or guidelines on how to integrate it into an existing project? If not, we may start off of this issue!

Thanks for your work.

@brancusi
Copy link

brancusi commented Jul 2, 2014

Would really like to get this working as well.

Thanks for all the work. Really excited about Orbit!

@pixelhandler
Copy link
Contributor

@brancusi @tute In my bower.json file I'm using local builds of orbit.js and ember-orbit using the path to the dist directory on my system like so:

    "orbit.js": "/Users/pixelhandler/code/orbitjs/orbit.js/dist",
    "ember-orbit": "/Users/pixelhandler/code/orbitjs/ember-orbit/dist"

Then in my Brocfile.js I'm importing the files like so:

app.import({
  development: 'vendor/orbit.js/orbit.amd.js',
  production: 'vendor/orbit.js/orbit.amd.min.js'
});

app.import({
  development: 'vendor/orbit.js/orbit-common.amd.js',
  production: 'vendor/orbit.js/orbit-common.amd.min.js'
});

app.import({
  development: 'vendor/orbit.js/orbit-common-jsonapi.amd.js',
  production: 'vendor/orbit.js/orbit-common-jsonapi.amd.min.js'
});

app.import({
  development: 'vendor/ember-orbit/ember-orbit.amd.js',
  production: 'vendor/ember-orbit/ember-orbit.amd.min.js'
});

Note that the above format is influx with ember-cli v.0.0.37 see http://git.io/H1GsPw

I'm still migrating to ember-cli so can't yet confirm that this setup is 100% the way to do but this is what I'm trying out for now.

@pixelhandler
Copy link
Contributor

Here is a diff for the setup I have so far: https://github.com/pixelhandler/blog/compare/try-ember-orbit-with-ember-cli

I'm trying to use JSONAPI for the source; however, I'm getting a JavaScript error, Source.orbitSourceClass must be initialized with an instance of an OC.Source

I'm using ember-orbit at commit: 8e4cd3c with ember-cli v0.0.37

[Error] Error: Assertion Failed: Source.orbitSourceClass must be initialized with an instance of an `OC.Source`

This is the initializer:

Orbit.Promise = Ember.RSVP.Promise;
Orbit.ajax = Ember.$.ajax;

var JSONAPIStore = EO.Store.extend({
  orbitSourceClass: OC.JSONAPISource,
  orbitSourceOptions: {
    host: PixelhandlerBlogENV.API_HOST,
    namespace: PixelhandlerBlogENV.API_PATH,
    idField: 'id'
  }
  //orbitSourceClass: new OC.JSONAPISource({
    //idField: 'id',
    //host: PixelhandlerBlogENV.API_HOST,
    //namespace: PixelhandlerBlogENV.API_PATH
  //}),
});

export default {
  name: 'ember-orbit',

  initialize: function(container, application) {
    application.register('schema:main', EO.Schema);

    //application.register('store:main', EO.Store);
    application.register('store:main', JSONAPIStore);
    application.inject('controller', 'store', 'store:main');
    application.inject('route', 'store', 'store:main');
  }
};

@dgeb
Copy link
Member

dgeb commented Jul 3, 2014

@pixelhandler I'm surprised that's still an issue. I'll pull down your blog this weekend (I'm on a family vacation now) and try to get you past this problem.

@tute I'd like to get ember-orbit working as an ember cli addon, as described in Robert Jackson's post. I'll also start this work in a few days.

@MatthewHager
Copy link

I just did an attempt at an Ember CLI addon. See my PR above.

@pixelhandler
Copy link
Contributor

@dgeb Hope you have a great vacation!

Don't worry about using my blog app to trouble shoot, Perhaps a simple demo app that uses OC.JSONAPISource and MemoryStore would be cool, like https://github.com/opsb/ember-orbit-todos but with REST + Memory connected (when/if you have time).

@tute
Copy link
Contributor Author

tute commented Jul 6, 2014

Closing this issue in favor of the PR: #9.

@tute tute closed this as completed Jul 6, 2014
@dgeb
Copy link
Member

dgeb commented Jul 7, 2014

@dgeb Hope you have a great vacation!

@pixelhandler thanks - we had a great time! Back and refreshed to tackle these issues now.

Don't worry about using my blog app to trouble shoot, Perhaps a simple demo app that uses OC.JSONAPISource and MemoryStore would be cool, like https://github.com/opsb/ember-orbit-todos but with REST + Memory connected (when/if you have time).

Such an example app is in the works. I also have a new Ruby lib that I'll be using to build the JSON API-compliant server.

Closing this issue in favor of the PR: #9.

@tute thanks - I'll follow up over there.

@opsb
Copy link
Contributor

opsb commented Jul 7, 2014

Such an example app is in the works. I also have a new Ruby lib that I'll be using to build the JSON API-compliant server.

@dgeb this sounds like exactly what I was intending to build (been stuck on other things unfortunately). Any idea when it'll be up on github? I'm hoping to get back on to the orbit related project next week and would be very happy to help out.

@dgeb
Copy link
Member

dgeb commented Jul 7, 2014

@opsb I'll try to have this project available within a week. Looking forward to the help - thanks in advance!

@csprocket777
Copy link

Did a JSONAPISource + MemoryStore example of the todos app ever get created? I'm lost on how to get this to work with a remote REST API server.

@opsb opsb mentioned this issue Jan 6, 2016
2 tasks
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

Successfully merging a pull request may close this issue.

7 participants