Anybody use Singleton models? This is the old way...
# suitecommerce
m
Anybody use Singleton models? This is the old way I would have created a singleton.
Copy code
return Backbone.Model.extend({
....
}, Singleton);
Not sure how to create in the newer syntax.
Copy code
var SCModel = SCModelModule.SCModel;
function ExtensionModule() {
  SCModel.call(this);
}
v
I had asked the same question a few weeks ago but didn’t get any answer. There is no official documentation for it either.
m
That's a bummer because I use Singleton's a lot in my extensions. I will just have to keep the old style until I figure it out.
g
Hi there @Viraj Shinde @Marvin, you can do it like this:
Copy code
var SCModel = SCModelComponent.SCModel;

        function MySCModel() {
            SCModel.call(this);
        }

        MySCModel.prototype = Object.create(SCModel.prototype);
        MySCModel.prototype.constructor = MySCModel;

        return _.extend(MySCModel, Singleton)
👍 2