helpers.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import Vue = require("vue");
  2. import {
  3. mapState,
  4. mapGetters,
  5. mapActions,
  6. mapMutations,
  7. createNamespacedHelpers
  8. } from "../index";
  9. const helpers = createNamespacedHelpers('foo');
  10. new Vue({
  11. computed: Object.assign({},
  12. mapState(["a"]),
  13. mapState('foo', ["a"]),
  14. mapState({
  15. b: "b"
  16. }),
  17. mapState('foo', {
  18. b: "b"
  19. }),
  20. mapState({
  21. c: (state: any, getters: any) => state.c + getters.c
  22. }),
  23. mapState('foo', {
  24. c: (state: any, getters: any) => state.c + getters.c
  25. }),
  26. mapGetters(["d"]),
  27. mapGetters('foo', ["d"]),
  28. mapGetters({
  29. e: "e"
  30. }),
  31. mapGetters('foo', {
  32. e: "e"
  33. }),
  34. helpers.mapState(["k"]),
  35. helpers.mapState({
  36. k: "k"
  37. }),
  38. helpers.mapState({
  39. k: (state: any, getters: any) => state.k + getters.k
  40. }),
  41. helpers.mapGetters(["l"]),
  42. helpers.mapGetters({
  43. l: "l"
  44. }),
  45. {
  46. otherComputed () {
  47. return "f";
  48. }
  49. }
  50. ),
  51. methods: Object.assign({},
  52. mapActions(["g"]),
  53. mapActions({
  54. h: "h"
  55. }),
  56. mapActions('foo', ["g"]),
  57. mapActions('foo', {
  58. h: "h"
  59. }),
  60. mapMutations(["i"]),
  61. mapMutations({
  62. j: "j"
  63. }),
  64. mapMutations('foo', ["i"]),
  65. mapMutations('foo', {
  66. j: "j"
  67. }),
  68. helpers.mapActions(["m"]),
  69. helpers.mapActions({
  70. m: "m"
  71. }),
  72. helpers.mapMutations(["n"]),
  73. helpers.mapMutations({
  74. n: "n"
  75. }),
  76. {
  77. otherMethod () {}
  78. }
  79. )
  80. });