Comments (9)
I think your code is wrong.
export default Ember.Route.extend({
model: function () {
return this.emberSync.find('user', '2oj9m');
},
actions: {
save: function () {
// do something cool
this.get('content').emberSync.save();
}
}
});
You need to read Ember.js' guide about what this.get('content')
is. I'm closing this, if you have other problems, let us know.
from ember-sync.
If after loading application I do this in the console:
var route = Ember.Namespace.NAMESPACES_BY_ID[''].__container__.lookup('route:index');
I get:
Class {routeName: "index", _names: Array[0], context: Class, currentModel: Class, controller: Class…}
then, when I type this:
var user = route.emberSync.createRecord('user', {name:'kurko'})
I get this:
Class {id: "8tp85", store: Class, container: Container, _changesToSync: Object, _deferredTriggers: Array[0]…}
and then when I type this:
user.emberSync.save()
I get this:
Class {__ember1412872464239: null, __nextSuper: undefined, __ember_meta__: Object, constructor: function, _super: function…}
Then I go to my firebase dashboard and I see that nothing has been added...
However, this: route.emberSync.find('user', '2oj9m')
works fine and returns a promise
https://github.com/codepreneur/embersync-localforage-example
from ember-sync.
@codepreneur did you find a solution to this? I'm running into a similar issue myself.
from ember-sync.
@codepreneur @csprocket777 I really don't have a way to debug this, but I'll be helping you with whatever I can. Can you perhaps put some debugger;
here and there and see what's going on?
Basically, if your Firebase adapter is similar to RESTAdapter
/LSAdapter
or any Ember compatible adapter, it'll be called according to that interface and it should work. If it works for RESTAdapter and not for Firebase, there's a possibility that your Firebase adapter is broken somehow because nothing is done on EmberSync side, except calling these adapters.
I've been using with ember-json-api
(online) and ember-local-storage-adapter
(offline) and it works fine.
from ember-sync.
For the record, here are my versions:
Ember: 1.9.1
Ember-Data: 1.0.0-beta.14
Handlebars: 2.0.0
jQuery: 2.1.3
I'm using the default REST adapter and the LocalStorage Ember-CLI add-on (kurko)
So I've been diving into the code to see if I can pin point where my issue is.
So far I've narrowed it down to a failing promise in ember-sync.js,
at this line: https://github.com/kurko/ember-sync/blob/master/dist/ember-sync.js#L448
The console error states:
undefined is not a function
Which is caused by a failure to generate relations, from the function "_this.generateRelationForRecord(type, relation);" here:
https://github.com/kurko/ember-sync/blob/master/dist/ember-sync.js#L655
(sorry for the rambling nature, I'm tracing my way through the code)
HERE'S THE CULPRIT
At: https://github.com/kurko/ember-sync/blob/master/dist/ember-sync.js#L678
There is a "record.serialize" call, except that in my case, the record is a promise that hasn't been resolved. This is where it fails for me.
I see there is a comment on line 638 to "implement for when .get(relation)
returns a Promise". That time might be now. 😉
In fact, removing the relationships from my model allows the online sync to occur. I'm wondering if there was a change in ember-data to ensure that ALL relationships returned promises by default (maybe they always did and I'm thinking wrong).
Further clarification, I have my "belongsTo" relationship set to async. Removing the async attribute allows the online sync to work as well. It boils down to the need to handle async relationships.
from ember-sync.
@csprocket777 you rock, sir!
Do you think you can code a PR to implement this? I'll do it myself but I can't guarantee when.
from ember-sync.
Ugh, I'm not sure how to approach implementing a solution. I'm not sure where to implement a promise to solve for this without breaking the whole thing. I'll play around and see if I can solve for this.
(I know this is alpha and I'm breaking the "don't use it in production yet" rule, but I'm doing it anyways because this solves a huge issue for me right now, and I'm under the gun)
from ember-sync.
@csprocket777 under the gun? 😱 🔫
You can hit me up at #emberjs channel on Freenode if you need. If you can at least write a failing spec in a PR, I'll try to make a patch tonight.
from ember-sync.
@csprocket777 from our conversation on IRC, here's a gist with what I think should be done: https://gist.github.com/kurko/7ca3b17fa6b7590b93a1
from ember-sync.
Related Issues (20)
- emberSync.save() creates the relevant object but does not save into the firebase
- Updating an exisitng model doesn't work HOT 3
- Setup per instructions, no online syncing happening HOT 8
- Project goal considering CouchDB and PouchDB HOT 1
- Cannot read property 'lookup' of undefined HOT 3
- post.async.get('comment') HOT 2
- TODO: implement for when '.get(relation)' returns a Promise HOT 1
- No container in JSONSerializer HOT 1
- Find records from offline store, then from online store only if not found HOT 2
- find records from server, relationship array not pushed to offline store HOT 1
- ember-sync/store/_serializeAssociations() prevent exception when relationships empty HOT 1
- Don't override the offlineStore records with empty records created on the online store due to id-only relationships fetched HOT 1
- Can you please let me know why I can't use EmberSync lib in my project? HOT 1
- EmberSync make another request when page is refreshed HOT 1
- offlineStore not saving when find new records from onlineStore HOT 2
- Look into https://github.com/api-hogs/ember-data-offline HOT 2
- small question about offline syncing HOT 1
- Assertion Failed: Passing classes to store methods has been removed. Please pass a dasherized string instead of my-new-app@model:ember-sync-queue-mode HOT 1
- Move to ud-sync organization
- Is this project still alive? Is it maintained? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-sync.