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

WIP: Mobx 5 support #868

Merged
merged 1 commit into from
Jun 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ test-lib/**/*.js
coverage
.nyc_output
.idea
package-lock.json
package-lock.json
.prettierignore
.vscode
.editorconfig
4 changes: 2 additions & 2 deletions packages/mobx-state-tree/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"cross-env": "^5.1.1",
"documentation": "^5.2.2",
"jest": "^22.4.2",
"mobx": "^4.0.2",
"mobx": "^5.0.2",
"rollup": "^0.43.0",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-filesize": "^1.3.2",
Expand All @@ -54,7 +54,7 @@
"typescript": "^2.7.0"
},
"peerDependencies": {
"mobx": "^4.0.2"
"mobx": "^5.0.2"
},
"keywords": [
"mobx",
Expand Down
4 changes: 2 additions & 2 deletions packages/mobx-state-tree/src/types/complex-types/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class ArrayType<S, T> extends ComplexType<S[], IObservableArray<T>> {

createNewInstance = () => {
const array = observable.array([], mobxShallow)
addHiddenFinalProp(array, "toString", arrayToString)
addHiddenFinalProp(_getAdministration(array).values, "toString", arrayToString)
return array
}

Expand All @@ -84,7 +84,7 @@ export class ArrayType<S, T> extends ComplexType<S[], IObservableArray<T>> {
}

getChildren(node: ObjectNode): INode[] {
return node.storedValue.peek()
return node.storedValue.slice()
}

getChildNode(node: ObjectNode, key: string): INode {
Expand Down
20 changes: 12 additions & 8 deletions packages/mobx-state-tree/src/types/complex-types/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
getAtom,
extendObservable,
observable,
_interceptReads
_interceptReads,
_getAdministration
} from "mobx"
import {
fail,
Expand Down Expand Up @@ -260,13 +261,16 @@ export class ModelType<S, T> extends ComplexType<S, T> implements IModelType<S,
const { value } = descriptor
if ("get" in descriptor) {
// TODO: mobx currently does not allow redefining computes yet, pending #1121
if (isComputed((self as any).$mobx.values[key])) {
if (isComputed(_getAdministration(self).values.get(key))) {
// TODO: use `isComputed(self, key)`, pending mobx #1120
;(self as any).$mobx.values[key] = computed(descriptor.get!, {
name: key,
set: descriptor.set,
context: self
})
_getAdministration(self).values.set(
key,
computed(descriptor.get!, {
name: key,
set: descriptor.set,
context: self
})
)
} else {
const tmp = {}
Object.defineProperty(tmp, key, {
Expand Down Expand Up @@ -382,7 +386,7 @@ export class ModelType<S, T> extends ComplexType<S, T> implements IModelType<S,

getChildNode(node: ObjectNode, key: string): INode {
if (!(key in this.properties)) return fail("Not a value property: " + key)
const childNode = node.storedValue.$mobx.values[key].value // TODO: blegh!
const childNode = _getAdministration(node.storedValue).values.get(key).value // TODO: blegh!
if (!childNode) return fail("Node not available for property " + key)
return childNode
}
Expand Down
2 changes: 1 addition & 1 deletion packages/mst-middlewares/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"ava": "^0.22.0",
"cross-env": "^5.1.1",
"lint-staged": "^4.3.0",
"mobx": "^4.0.2",
"mobx": "^5.0.2",
"mobx-state-tree": "^2.1.0",
"rollup": "^0.50.0",
"rollup-plugin-commonjs": "^8.2.5",
Expand Down
50 changes: 30 additions & 20 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7783,18 +7783,19 @@ mobx-react-devtools@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/mobx-react-devtools/-/mobx-react-devtools-5.0.1.tgz#9473c85929b2fc0c95086430419028cebd96fb3b"

mobx-react@^4.3.3:
version "4.3.3"
resolved "https://registry.yarnpkg.com/mobx-react/-/mobx-react-4.3.3.tgz#4ad76c03d1e942b431e942f9ea18df0756771655"
dependencies:
hoist-non-react-statics "^2.3.1"

mobx-react@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/mobx-react/-/mobx-react-5.0.0.tgz#8d5a33be376fa22b184a6f555d40a6a3a8459a16"
dependencies:
hoist-non-react-statics "^2.3.1"

mobx-react@^5.2.3:
version "5.2.3"
resolved "https://registry.yarnpkg.com/mobx-react/-/mobx-react-5.2.3.tgz#cdf6141c2fe63377c5813cbd254e8ce0d4676631"
dependencies:
hoist-non-react-statics "^2.5.0"
react-lifecycles-compat "^3.0.2"

mobx-utils@^2.0.1:
version "2.0.2"
resolved "https://registry.yarnpkg.com/mobx-utils/-/mobx-utils-2.0.2.tgz#c12c9cc69be8020e30c7b6417f14b4ea38ba9723"
Expand All @@ -7803,14 +7804,18 @@ [email protected]:
version "3.1.15"
resolved "https://registry.yarnpkg.com/mobx/-/mobx-3.1.15.tgz#b2c8831725de2f6f1b8d136e589b674b5b75c35d"

mobx@^3.3.0:
version "3.3.1"
resolved "https://registry.yarnpkg.com/mobx/-/mobx-3.3.1.tgz#c38fc1a287a0dda3f5d4b85efe1137fedd9dcdf0"

mobx@^4.0.2:
version "4.1.0"
resolved "https://registry.yarnpkg.com/mobx/-/mobx-4.1.0.tgz#e4a9679cdafbe215b20e32ef93a7031845b3f1af"

mobx@^4.3.1:
version "4.3.1"
resolved "https://registry.yarnpkg.com/mobx/-/mobx-4.3.1.tgz#334e5aab4916b1d43f0faf3605a64b1b4b3ccb8d"

mobx@^5.0.2:
version "5.0.2"
resolved "https://registry.yarnpkg.com/mobx/-/mobx-5.0.2.tgz#ea8d208eb36e9443707230d77a250f2fdd295dfb"

modify-values@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/modify-values/-/modify-values-1.0.0.tgz#e2b6cdeb9ce19f99317a53722f3dbf5df5eaaab2"
Expand Down Expand Up @@ -9297,20 +9302,21 @@ react-dom@^15.3.0, react-dom@^15.5.0:
object-assign "^4.1.0"
prop-types "^15.5.10"

react-dom@^16.3.1:
version "16.3.1"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.3.1.tgz#6a3c90a4fb62f915bdbcf6204422d93a7d4ca573"
react-dom@^16.4.0:
version "16.4.0"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.4.0.tgz#099f067dd5827ce36a29eaf9a6cdc7cbf6216b1e"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.0"

react-draggable@1.3.7:
version "1.3.7"
resolved "https://registry.yarnpkg.com/react-draggable/-/react-draggable-1.3.7.tgz#729bde4bd1e717c395b228c775e837695d50c2b2"
react-draggable@3.0.5:
version "3.0.5"
resolved "https://registry.yarnpkg.com/react-draggable/-/react-draggable-3.0.5.tgz#c031e0ed4313531f9409d6cd84c8ebcec0ddfe2d"
dependencies:
classnames "^2.2.0"
classnames "^2.2.5"
prop-types "^15.6.0"

react-error-overlay@^2.0.2:
version "2.0.2"
Expand All @@ -9335,6 +9341,10 @@ react-hot-loader@^4.0.1:
prop-types "^15.6.1"
shallowequal "^1.0.2"

react-lifecycles-compat@^3.0.2:
version "3.0.4"
resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362"

react-redux@^4.4.5:
version "4.4.8"
resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-4.4.8.tgz#e7bc1dd100e8b64e96ac8212db113239b9e2e08f"
Expand Down Expand Up @@ -9421,9 +9431,9 @@ react@^15.3.0, react@^15.5.0:
object-assign "^4.1.0"
prop-types "^15.5.10"

react@^16.3.1:
version "16.3.1"
resolved "https://registry.yarnpkg.com/react/-/react-16.3.1.tgz#4a2da433d471251c69b6033ada30e2ed1202cfd8"
react@^16.4.0:
version "16.4.0"
resolved "https://registry.yarnpkg.com/react/-/react-16.4.0.tgz#402c2db83335336fba1962c08b98c6272617d585"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.1.0"
Expand Down