Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mobx-decorated-models

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobx-decorated-models - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

8

dist/build.full.js

@@ -16,3 +16,3 @@ (function (global, factory) {

var modelName = options.className ? options.className : propertyName;
var modelName = options.classId || propertyName;
return ModelsMap[modelName] || ModelsMap[capitalize(modelName)];

@@ -372,3 +372,3 @@ };

var modelClass = _ref4.modelClass,
className = _ref4.className,
classId = _ref4.classId,
defaultAttributes = _ref4.defaults,

@@ -382,3 +382,3 @@ inverseOf = _ref4.inverseOf;

if (!modelClass) {
modelClass = findModel(className);
modelClass = findModel(classId);
}

@@ -402,3 +402,3 @@ if (change.type === 'splice') {

var ary = mobx.observable.array([]);
if (options.className || options.modelClass) {
if (options.classId || options.model) {
ary.intercept(onCollectionChangeInterceptor(options, parentModel, parentModelProp));

@@ -405,0 +405,0 @@ }

@@ -13,3 +13,3 @@ import { createModelSchema, deserialize, getDefaultModelSchema, identifier, list, object, primitive, serialize, update } from 'serializr';

var modelName = options.className ? options.className : propertyName;
var modelName = options.classId || propertyName;
return ModelsMap[modelName] || ModelsMap[capitalize(modelName)];

@@ -369,3 +369,3 @@ };

var modelClass = _ref4.modelClass,
className = _ref4.className,
classId = _ref4.classId,
defaultAttributes = _ref4.defaults,

@@ -379,3 +379,3 @@ inverseOf = _ref4.inverseOf;

if (!modelClass) {
modelClass = findModel(className);
modelClass = findModel(classId);
}

@@ -399,3 +399,3 @@ if (change.type === 'splice') {

var ary = observable.array([]);
if (options.className || options.modelClass) {
if (options.classId || options.model) {
ary.intercept(onCollectionChangeInterceptor(options, parentModel, parentModelProp));

@@ -402,0 +402,0 @@ }

@@ -8,3 +8,3 @@ const ModelsMap = new Map();

const defaultModelLookup = (propertyName, options = {}) => {
const modelName = options.className ? options.className : propertyName;
const modelName = options.classId || propertyName;
return ModelsMap[modelName] || ModelsMap[capitalize(modelName)];

@@ -11,0 +11,0 @@ };

@@ -65,3 +65,3 @@ import { observable, intercept } from 'mobx';

function onCollectionChangeInterceptor(
{ modelClass, className, defaults: defaultAttributes, inverseOf },
{ modelClass, classId, defaults: defaultAttributes, inverseOf },
parentModel, parentModelProp,

@@ -74,3 +74,3 @@ ) {

if (!modelClass) {
modelClass = findModel(className);
modelClass = findModel(classId);
}

@@ -94,3 +94,3 @@ if (change.type === 'splice') {

const ary = observable.array([]);
if (options.className || options.modelClass) {
if (options.classId || options.model) {
ary.intercept(onCollectionChangeInterceptor(options, parentModel, parentModelProp));

@@ -97,0 +97,0 @@ }

{
"name": "mobx-decorated-models",
"version": "0.4.0",
"version": "0.4.1",
"description": "Decorators to make using Mobx for model type structures easier",

@@ -5,0 +5,0 @@ "main": "dist/build.full.js",

@@ -83,3 +83,3 @@ # Decorators for creating model type structures with mobx

class Table {
hasMany({ className: 'chair' }) 'seats'
hasMany({ classId: 'chair' }) 'seats'
}

@@ -103,3 +103,3 @@ ```

lookupModelUsing((propertyName, propertyOptions) => {
return Models[propertyOptions.className] ||
return Models[propertyOptions.classId] ||
Models[capitalize(propertyName)] ||

@@ -119,3 +119,3 @@ Models[capitalize(singularize(propertyName))];

static identifiedBy = 'document';
hasMany({ className: 'test' }) testRuns;
hasMany({ classId: 'test' }) testRuns;
}

@@ -171,3 +171,3 @@ ```

Optionally can be given an option object with a `className` property to control the mapping.
Optionally can be given an option object with a `classId` property to control the mapping.

@@ -182,3 +182,3 @@

@field name;
@belongsTo({ className: 'Pants', inverseOf: 'owner' }) outfit;
@belongsTo({ classId: 'Pants', inverseOf: 'owner' }) outfit;
})

@@ -189,3 +189,3 @@

@session color;
@belongsTo({ className: 'Person' }) owner; // looks for class `Person`
@belongsTo({ classId: 'Person' }) owner; // looks for class `Person`
}

@@ -212,3 +212,3 @@ ```

As in `belongsTo`, can be optionally given an option object with a `className` property to control the mapping.
As in `belongsTo`, can be optionally given an option object with a `classId` property to control the mapping.

@@ -233,3 +233,3 @@ `hasMany` also accepts `inverseOf` and `defaults` properties. If an inverseOf is provided,

@session color;
@hasMany({ className: 'Tire', inverseOf: 'vehicle', defaults: {numberInSet: 4} }) tires;
@hasMany({ classId: 'Tire', inverseOf: 'vehicle', defaults: {numberInSet: 4} }) tires;
}

@@ -241,3 +241,3 @@

@hasMany({
className: 'Car',
classId: 'Car',
inverseOf: 'home',

@@ -244,0 +244,0 @@ defaults(collection, parent) {

@@ -52,3 +52,3 @@ import { observable, computed } from 'mobx';

@hasMany({
className: 'box',
classId: 'box',
inverseOf: 'container',

@@ -55,0 +55,0 @@ defaults() {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc