-
Notifications
You must be signed in to change notification settings - Fork 3
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
Replace can.Model with CanModel #2
Comments
Replace can.Model with CanModelMy understanding is that this codemod should perform the following transformation: ---------|----------- 2.x ------------|---------------------- 3.0 ------------------------------- How should this codemod handle this if it is deprecated in 3.0?Can Model in 3.0 Edge CasesIs there anything I should keep in mind? /cc @chasenlehara @justinbmeyer - let me know if I'm on the right track and how to handle a feature that is deprecated. |
var Todo = can.Model.extend({
id: "_ID",
findAll: X1,
findOne: X2,
create: X3,
update: X4,
destroy: X5,
parseModels: PMPROP
},PROTOTYPE_OBJECT); var connectBaseMap = require("can-connect/can/base-map/base-map");
var CanMap = require("can-map");
var set = require("can-set");
var Todo = CanMap.extend(PROTOTYPE_OBJECT);
Todo.algebra = new set.Algebra(
set.props.id("_ID")
);
connectBaseMap({
Map: Todo,
url: {
getListData: X1,
getData: X2,
createData, updateData, destroyData
},
algebra: Todo.algebra,
parseListProp: PMPROP
}); can-connect/can/base-map/base-map");
var DefineMap = require("can-define/map/map");
var constructor = require("can-connect/constructor/constructor");
var canMap = require("../map/map");
var canRef = require("../ref/ref");
var constructorStore = require("../../constructor/store/store");
var dataCallbacks = require("../../data/callbacks/callbacks");
var callbacksCache = require("../../data/callbacks-cache/callbacks-cache");
var dataParse = require("../../data/parse/parse");
var dataUrl = require("../../data/url/url");
var callbacksOnce = require("../../constructor/callbacks-once/callbacks-once");
var GLOBAL = require("can-util/js/global/global");;
var Todo = DefineMap.extend(PROTOTYPE_OBJECT);
connect([
constructor,
canMap,
canRef,
constructorStore,
dataCallbacks,
dataParse,
dataUrl,
callbacksOnce
],{
Map: Todo,
url: {
getListData: X1,
getData: X2,
createData, updateData, destroyData
}
}); |
One edge case: can.Model.extend() in 2.x would add the model class to the global namespace if you gave it a string as the first argument (in fact, all can.Constructs did this). In 3.0 this no longer happens, so old code that expects Maps/Models/Constructs to be on the global namespace will break. Does codemods support flags? We could support an optional --globalize-classes:
|
No description provided.
The text was updated successfully, but these errors were encountered: