What I want to do is create an object by doing some xhr requests in the constructor. Is this considered a bad practice?
I'm using jquery promises to attach them to the object in the constructor so I'll have something like this:
obj = new MyObj(params);
obj.done(func)
obj.fail(errFunc)
Which looks good and clean but I'm not sure how good of a practice it is considering that my obj is now both a normal obj on which I set props in the constructor but also a promise.
Other then this, I didn't see any other promises implementation that let's you attach a promise to an existing object (correct me if I'm wrong) in case I want to switch from the jquery implementation.
Quote from jquery doc:
If target is provided, deferred.promise() will attach the methods onto it and then return this object rather than create a new one. This can be useful to attach the Promise behavior to an object that already exists.