
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
bem-promised-models
Advanced tools
BEM wrapper for promised-models2
priv.js
with bem-node's i-state
$ npm install --save bem-promised-models
Add node_modules/bem-promised-models/blocks
to your levels lists
Add deps for promised-models
({
mustDeps: [
{block: 'promised-models', elems: ['model', 'registry', 'registry-storage']}
]
})
For noBEM setups use promised-models2
BEM.Model.decl('fashion-model', {
attributes: {
name: {
type: 'String'
}
}
});
var model = BEM.blocks['fashion-model'].create({
name: 'Kate'
});
model.get('name'); //Kate
Add declaration for existent one:
BEM.Model.decl('fashion-model', {
attributes: {
sename: {
type: 'String'
}
},
getFullName: function () {
return [this.get('name') + this.get('sename')].join(' ');
}
});
var model = BEM.blocks['fashion-model'].create({
name: 'Kate',
sename: 'Moss'
});
model.getFullName(); //Kate Moss
Inherit:
BEM.Model.decl('uppercased-model', 'fashion-model', {
getFullName: function () {
return this.__base().toUpperCase();
}
});
BEM.Model.decl('podium', {
attributes: {
//nested
currentModel: {
type: 'Model',
modelType: 'fashion-model'
},
//collections
avaibleModels: {
type: 'ModelsList',
modelType: 'fashion-model'
}
}
});
//bh template
var model = BEM.blocks['fashion-model'].create();
ctx.content({
block: 'view',
js: {
modelId: model.cid
}
});
//BEM.DOM declaration
var model = BEM.blocks['fashion-model'].getOne(this.params.modelId);
var model = BEM.blocks['fashion-model'].getAny(this.params.mongoId);
//load data from storage
model.fetch().done();
BEM.Model.decl('fashion-model', {
storage: {
insert: function (model) {
//...
},
update: function (model) {
//...
},
find: function (model) {
//...
},
remove: function (model) {
//...
}
}
});
.decl(modelName, [baseModel], [properties], [staticProperties])
Add model declaration
.getOne([cid])
Get model instance by client id model.cid
.create([id], [data])
Create model instance with storage id and data
.getOne([cid])
Get model instance of current class by client id model.cid
.getAny([id])
Get model instance by storage id model.id
. If no instance with id
was found, create new one.
See promised-models2
FAQs
BEM wrapper for promised-models
The npm package bem-promised-models receives a total of 2 weekly downloads. As such, bem-promised-models popularity was classified as not popular.
We found that bem-promised-models demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.