-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
chore(dep/vue) bump peerDep composition-api to 0.6 #1253
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
'@xstate/vue': minor | ||
--- | ||
|
||
chore(dep/vue) bump peerDep of @vue/composition-api to 0.6.x. | ||
|
||
- breaking changes in 0.6.x, adapated code. Will make it easier for | ||
this library to also be updated to Vue 3. | ||
- Uses new watcher option since it was changed to be lazy by default | ||
- now using shallow ref since xstate objects should not be refs deeply. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ | |
"url": "https://github.com/davidkpiano/xstate/issues" | ||
}, | ||
"peerDependencies": { | ||
"@vue/composition-api": "^0.3.4", | ||
"@vue/composition-api": "^0.6.5", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we depend on some features in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can change it. there were bugs caught in 0.6.0->.4 within a few days so didn't want to point to versions that were knowingly buggy but I suppose that's for the consumer to figure out? Was curious why it wasn't ^0.3.0 |
||
"@xstate/fsm": "^1.0.0", | ||
"vue": "^2.6.10", | ||
"xstate": "^4.7.8" | ||
|
@@ -57,7 +57,7 @@ | |
"devDependencies": { | ||
"@testing-library/jest-dom": "^4.2.4", | ||
"@testing-library/vue": "^4.1.0", | ||
"@vue/composition-api": "^0.3.4", | ||
"@vue/composition-api": "~0.6.5", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any reason why this is using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, changing back. I was initially going to try and provide backward compat, but not anymore |
||
"@vue/test-utils": "^1.0.0-beta.30", | ||
"@xstate/fsm": "*", | ||
"babel-core": "^6.26.3", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
</template> | ||
|
||
<script lang="ts"> | ||
import Vue, { PropType } from 'vue' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, I don't see |
||
import { useService } from '../src'; | ||
import { | ||
Machine, | ||
|
@@ -14,20 +15,24 @@ import { | |
spawn, | ||
doneInvoke, | ||
State, | ||
Service | ||
} from 'xstate'; | ||
import { watch, ref } from '@vue/composition-api'; | ||
import { watchEffect, ref, Ref } from '@vue/composition-api'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea found these test .vue files are hard to type/lint. Will clean them up a bit. |
||
|
||
export default { | ||
props: ['service'], | ||
setup(props): { service: Service } { | ||
props: { | ||
service: { | ||
type: Object as PropType<Interpreter<any>>, | ||
} | ||
}, | ||
setup(props) { | ||
let { state, send } = useService(props.service); | ||
|
||
watch(() => { | ||
watchEffect(() => { | ||
let currentState = useService(props.service); | ||
state.value = currentState.state.value; | ||
send = currentState.send; | ||
}); | ||
|
||
return { state, send }; | ||
} | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefixes like
chore(dep/vue)
are not needed, the changelog entry created later because of this changeset file will only appear in the./packages/xstate-vue/CHANGELOG.md
so no need to include this information here. A changeset should also only describe user-facing changes, no need to mention that, for example, a new watcher option has been used internally - it's just an implementation detail.I propose to change this to something like this:
Which assumes that previously exposed refs were deep, which I don't know if it was true nor what does it actually mean in context of Vue. Would love to learn more if you have a spare moment to explain this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Migrating to 0.6 seems to have changed how
ref
returns were typed. So actually I think it could work with traditional ref's if the type error could be resolved:^^not sure how to resolve the
UnwrapRef<TContext>
typing.A traditional ref will allow for an object's properties and sub-properties to be reactive. The "gotcha" with a shallowRef is that members are not reactive.
shallowRef
's continue to allow@xstate/vue
to work since allref
assignments used are wholesale replaced e.g.current.value =
orstate.value =
(vs.state.value.value =
). However, this is a breaking change if users were wanting to mutate return ref's properties directly and still have reactivity like today, e.g. ifstate.value.value
is assigned directly instead of viasend
, it would not trigger any vue reactivity (watchers, computed, template updates etc.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, is it Proxy-based?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the composition-api is not proxy based, though
vue-next
(v3) is