Skip to content
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

Mobx model 1.0 master branch #37

Open
wants to merge 52 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
64f5aa8
Update README
Staltec Aug 9, 2019
f485fc2
Update CHANGELOG
Staltec Aug 9, 2019
e9b6730
Update module version
Staltec Aug 9, 2019
a04334b
Remove API and REST-actions
Staltec Aug 9, 2019
d5c8b8c
Update tests
Staltec Aug 9, 2019
97540ad
Code formatting
Staltec Aug 9, 2019
cb2df56
Merge pull request #38 from wearevolt/Remove_API_and_actions
Staltec Aug 9, 2019
d9644a1
Update babel version to 7.5
Staltec Aug 9, 2019
be2090e
Add config() method and update Tests
Staltec Aug 9, 2019
8dbfdea
Yarn
Staltec Aug 9, 2019
4fbbd66
Rename model class file
Staltec Aug 9, 2019
3449caf
Cleanup code
Staltec Aug 12, 2019
8a58af7
Add mobx as external dependence by config()
Staltec Aug 12, 2019
f017e09
Make mobx as external dependency
Staltec Aug 12, 2019
d9a2c39
Make mobx as external dependency tests
Staltec Aug 12, 2019
cf2852c
Implement plugins support + test coverage
Staltec Aug 13, 2019
2f4dda5
Remove unused code from tests
Staltec Aug 13, 2019
4db8c38
Add class type definitions
Staltec Aug 13, 2019
25fc440
Lock dependence versions
Staltec Aug 13, 2019
be31d4c
Make plugins option as optional config option
Staltec Aug 14, 2019
47f2d27
Fix plugin type definition
Staltec Aug 15, 2019
a057767
Add action and class action name auto calc by action method name
Staltec Aug 15, 2019
17863c5
Add exception if action method is empty
Staltec Aug 15, 2019
ddcfa6f
Add attribute and relation decorators
Staltec Aug 20, 2019
945eb47
Fix type definitions
Staltec Aug 23, 2019
3aa5880
Fix onDestroy method
Staltec Aug 23, 2019
f7e550c
Deprecate onDestroy() method as model destroyer
Staltec Aug 27, 2019
aa5d0bc
fix get and set definition
Staltec Sep 4, 2019
2ceea14
Add some static property declarations
Staltec Sep 7, 2019
828721c
Increase version to 1.0.1
Staltec Sep 7, 2019
cbaa88b
Initialize TS
Staltec Sep 24, 2019
ebef8aa
Decorators and utils
Staltec Sep 24, 2019
e6bcad5
JS -> TS
Staltec Sep 24, 2019
7b52b92
Fix inflection import in module
Staltec Sep 24, 2019
73cc90c
Make build by TS + increase module version to 1.0.2
Staltec Sep 24, 2019
9f424d9
Fix inflection type definition
Staltec Sep 26, 2019
df7b0aa
Remove urlRoot
Staltec Sep 26, 2019
beafabe
Code refactoring
Staltec Sep 26, 2019
7cf08ad
Add option type
Staltec Sep 26, 2019
a40c2cc
Merge pull request #39 from wearevolt/Rewrite_by_TypeScript
Staltec Sep 26, 2019
3cbef63
Dynamic type definitions build on publish
Staltec Sep 27, 2019
113d066
Remove old type definitions
Staltec Sep 27, 2019
838d9d1
Update definition types for relation types
Staltec Sep 27, 2019
7ab1843
Issue test coverage
Staltec Apr 17, 2020
2a02ffa
Fix issue
Staltec Apr 17, 2020
d2915fa
Merge pull request #43 from wearevolt/Bug/Wrong_boolean_attribute_val…
Staltec Apr 17, 2020
43e462e
Bump version to 1.0.12 cause issue #41 fixed
Staltec Apr 17, 2020
c38b635
Make issue 44 tests
Staltec May 14, 2020
db6ff4b
Fix MobxModel get() method: set nill id arg cause unexpected
Staltec May 14, 2020
62e75a9
Bump version to 1.0.13 cause issue #44 fixed
Staltec May 14, 2020
f873139
Code formatting
Staltec May 14, 2020
1b4f917
Merge pull request #45 from wearevolt/Feature/81069_mobxmodel_get()_m…
Staltec May 14, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ lib/
node_modules/
npm-debug.log
_book
.idea
.idea
*.d.ts
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
## Changelog

### 1.0.0
Next step of MobxModel

1. Use `mobx` as external dependence.
2. Configuration method for models registration and any setup options.
3. Add plugins support.
4. Remove API and REST-actions as part of library. Now they must be implemented as external plugins.
5. Rename `BaseModel` class to `MobxModel`
6. Type definitions for TypeScript

### 0.0.39

Updated mobx to 3.2.2
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Mobx-model [![npm version](https://badge.fury.io/js/mobx-model.svg)](https://badge.fury.io/js/mobx-model)
# Mobx-model 1.0 [![npm version](https://badge.fury.io/js/mobx-model.svg)](https://badge.fury.io/js/mobx-model)

This is a library to simplify [mobx](https://github.com/mobxjs/mobx) data stores that mimic backend models. It includes simple class that makes API requests and executes callbacks on success/failure. Model attributes and relations are then updated from server-side json. Note that you will need es6 support with static properties to use mobx-model.

The idea is to have single source of truth — graph of model objects that reference each other. Each model class holds collection of cached model instances available through `Model.all()` and `Model.get(:id)` methods.
The idea is to have single source of truth — graph of model objects that reference each other. Each model class holds collection of cached model instances available through `Model.all()` and `Model.get(:id)` methods.

Mobx-model is not a replacement for Backbone.Model since it supports single source of truth principle. Model instance methods that are created by defining attributes and relations are intended to be used as a way to access state of the models. To hydrate the state you have to use `set` method on an instance or a class, that will set or update your model attributes and trigger re-renders on appropriate components thanks to `mobx-react`.
Mobx-model is not a replacement for Backbone.Model since it supports single source of truth principle. Model instance methods that are created by defining attributes and relations are intended to be used as a way to access state of the models. To hydrate the state you have to use `set` method on an instance or a class, that will set or update your model attributes and trigger re-renders on appropriate components thanks to `mobx-react`.

You can also define actions on model classes or instances or on the `BaseModel` itself that will communicate with your data store — API, localstorage or whatever you need, just make sure to call `set` when you need to update state of the models.

This library is not perfect, but it works for us together with Rails + ActiveModel Serializers 0.8.3 on the backend, making work with normalized database structure much easier. If you want to make it work with your backend setup then raise an issue — I'll be glad to help you out to make library universal.
This library is not perfect, but it works for us together with Rails + ActiveModel Serializers 0.8.3 on the backend, making work with normalized database structure much easier. If you want to make it work with your backend setup then raise an issue — I'll be glad to help you out to make library universal.

Note that currently polymorphic associations are not supported, though there are some workarounds.
Note that currently polymorphic associations are not supported, though there are some workarounds.
6 changes: 6 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
presets: ['@babel/preset-env'],
"plugins": [
["@babel/plugin-proposal-class-properties"]
]
};
Loading