Skip to content

Need Backbone support for latest SDK #43

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

Closed
mohansn opened this issue Oct 5, 2015 · 12 comments
Closed

Need Backbone support for latest SDK #43

mohansn opened this issue Oct 5, 2015 · 12 comments

Comments

@mohansn
Copy link

mohansn commented Oct 5, 2015

I am currently building an backbone app (items added to a table for each Google form submitted for review). I am on parse 1.2.13 JS SDK.

Migrating to 1.6 will obviously mess up my working code since there is no Collection class.

I am somewhat new to web development. Could someone let me know if Backbone support is in the works or if there is a simple workaround?

Thanks!

@typhonrt
Copy link

typhonrt commented Oct 5, 2015

There is no simple workaround and Parse / FB is not going to do it because you know, React! Good news is that I'm almost done with creating a Backbone 1.2.3 fork that works fully with Parse 1.6. About 95% of the way there at this point pending a little more testing. I should have it done this week and open sourced. Nice thing too is that I modularized Backbone and made it ES6 making it easy to modify it in a clean way. I'll also be distributing minimal / lightweight ES5 bundles designed to be consumed in various module systems (RequireJS, SystemJS, etc.) along with an all inclusive bundle designed for global usage.

@mohansn
Copy link
Author

mohansn commented Oct 6, 2015

Thanks a million, @typhonrt ! Looking forward to it.

@cfoulston
Copy link

My app just came to a screeching halt because of this. Looking forward to your implementation typhonrt.

The least Parse could do is provide a migration guide or something.

@typhonrt
Copy link

@cfoulston Thanks for reminding me of this issue...

I've had the repos up for a week or so, but have been polishing off documentation and I have still to get a repo up for a full SystemJS / JSPM demo which is a great way to consume the ES6 source. If you want to check things out though the Backbone-Parse-ES6 repo is: https://github.com/typhonjs-parse/backbone-parse-es6

The /dist directory has various ES5 bundles for AMD, CJS, and global consumption.

If you weren't using Backbone / Parse previously with a module system you'll want to choose the global bundles. The basic global bundle has Backbone & Parse. You'll need to load Underscore & a jQuery equivalent via script tags before the backbone-parse library. The "global inclusive" bundle also contains Underscore and jQuery.

and the main SystemJS / JSPM + global demo will be up here before the end of the week most likely:

Technically you should be able to use things just like before and I have a whole framework on top of Backbone that works, but that doesn't mean I have all the angles tested. I'm going to be updating to Backbone 1.2.4 / or the next latest release and port over all of the tests from the original Backbone repo at that time and also see if I can come up with some way of auto-testing Parse thoroughly.

Drop an issue in the repos for questions.

@ghost
Copy link

ghost commented Nov 17, 2016

@typhonrt I have an old parse project which uses JS SDK 1.2.12, Can I use your library as a drop in replacement for parse library? I'm already using require-js for my modules like,

define(
[
    'jquery',
    'underscore', 
    'parse',
    'models/Comment',
    'collections/Comments'
], function($, _, Parse, Comment, Comments)
{
}
);

Do I need to make code changes in every file to get it work with new parse open-source server?

@typhonrt
Copy link

typhonrt commented Nov 17, 2016

Unfortunately RequireJS support is a bit challenging. There is an existing issue: typhonjs-backbone-parse/backbone-parse-es6#8 regarding RequireJS support where I detail the problem. A small change to the Parse JS SDK could solve the problem: #144, but @andrewimm has not weighed in on the solution. backbone-parse-es6 does support JSPM and potentially other package managers. More or less my hands are tied in being able to support RequireJS easily.

@ghost
Copy link

ghost commented Nov 17, 2016

@typhonrt Thank you so much for the prompt response. Could you please point a PR or add somewhere the changes required in Parse JS SDK, so we can continue with AMD module from your repo?

@typhonrt
Copy link

We'll my hands are tied as I'm not involved with Parse and #144 has gone without answer or confirmation from @andrewimm for months, so a PR is pointless as it will just sit by the wayside as well most likely. There is a simple solution; Parse.encode = encode; Parse.decode = decode; in Parse.js, but if I can't get FB to acknowledge it then it's beyond what I can do personally. I already provided the only community solution to the outright abandonment of Backbone in regard to Parse.

It works great for modern package managers such as JSPM presently. It's not like I don't want to support legacy solutions like RequireJS as well, but such is life. Upgrading your web app while taking more work to use JSPM, Webpack, etc. will solve things. I've posted the solution above, but it's a crapshoot if FB will add it to the JS SDK.

Unfortunately the solution to typhonjs-backbone-parse/backbone-parse-es6#5 outweighs the side effect of breaking easy RequireJS support, but once again a small modification to the Parse JS SDK would allow things to proceed with full RequireJS support out of the box. Contact the Parse team and let them know you'd like to see this solved.

@ghost
Copy link

ghost commented Dec 2, 2016

I'm using parse-bone with require-js with few modifications to remove the wrapper and it is working as expected. Thanks for your support @typhonrt

@typhonrt
Copy link

typhonrt commented Dec 2, 2016

@midhunanew parse-bone may work for now and is the best drop in replacement, but likely won't see much further progress. I guess the difference with https://github.com/typhonjs-backbone-parse/backbone-parse-es6 is that I am supporting the latest Backbone release and updates and you can use the latest version of the Parse JS SDK.

The problem I outlined above is that to get nested pointer relationships to encode / save correctly I have to directly access the encode file of the Parse JS SDK. This makes usage in RequireJS a bit messy. I haven't tried all too hard to get it working as well I don't need that functionality as modern package managers solve the problem transparently. I gather one can duplicate the parse JS SDK to create a hack workaround with RequireJS, but it's not clean per se. I'm not getting paid for any of this so can't exactly focus on this since there is such an easy solution if the Parse JS team takes my suggestion up for consideration. The problem is that encode.js references a bunch of other internal Parse JS files and the dependencies continue to chain up to foul things up w/ RequireJS. If it were exposed via Parse.js / ala Parse.encode(...) there would be no problem.

@lockwobr
Copy link

So I know that this a bit old but was able to fix a lot of the bugs in are parse code by doing this close to start of the page load. Hope this helps other solve this problem.

define (['underscore', 'parse', 'backbone'],  function (_, Parse, Backbone) {
	Parse.Collection = Backbone.Collection;

	function extend(obj, destination, source) {
		
		for (var k in source) {
			if (!destination.hasOwnProperty(k)) {
				obj[k] = source[k];
			}
		}
  		return obj; 
	};

	// add all methods that are in backbone and not in parse, to make it more like the old parse library
	extend(Parse.Object.prototype, Parse.Object.prototype, Backbone.Model.prototype);

       var models = {};
       models.Campaign = Parse.Object.extend({
       // parse model logic 
       });
     
    return models;
});

@stale
Copy link

stale bot commented Feb 6, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Feb 6, 2019
@stale stale bot closed this as completed Feb 13, 2019
@dplewis dplewis removed the stale label Oct 22, 2020
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