How to use the typed-vuex.actionTree function in typed-vuex

To help you get started, we’ve selected a few typed-vuex examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nurdism / neko / client / src / store / chat.ts View on Github external
delEmote(state, id: string) {
    const emotes = {
      ...state.emotes,
    }
    delete emotes[id]
    state.emotes = emotes
  },

  reset(state) {
    state.emotes = {}
    state.history = []
  },
})

export const actions = actionTree(
  { state, getters, mutations },
  {
    newEmote(store, emote: Emote) {
      if (accessor.settings.ignore_emotes || document.visibilityState === 'hidden') {
        return
      }

      const id = makeid(10)
      accessor.chat.addEmote({ id, emote })
    },

    newMessage({ state }, message: Message) {
      if (accessor.settings.chat_sound) {
        new Audio('chat.mp3').play().catch(console.error)
      }
      accessor.chat.addMessage(message)
github nurdism / neko / client / src / store / emoji.ts View on Github external
state.groups[0].list.push(emoji)
      set('emoji_recent', JSON.stringify(state.groups[0].list))
    }
  },
  addGroup(state, group: Group) {
    state.groups.push(group)
  },
  setKeywords(state, keywords: Keywords) {
    state.keywords = keywords
  },
  setList(state, list: string[]) {
    state.list = list
  },
})

export const actions = actionTree(
  { state, getters, mutations },
  {
    initialise() {
      $http
        .get('/emoji.json')
        .then((req) => {
          for (const group of req.data.groups) {
            accessor.emoji.addGroup(group)
          }
          accessor.emoji.setList(req.data.list)
          accessor.emoji.setKeywords(req.data.keywords)
        })
        .catch(console.error)
    },
  },
)
github nurdism / neko / client / src / store / remote.ts View on Github external
setClipboard(state, clipboard: string) {
    state.clipboard = clipboard
  },

  setLocked(state, locked: boolean) {
    state.locked = locked
  },

  reset(state) {
    state.id = ''
    state.clipboard = ''
    state.locked = false
  },
})

export const actions = actionTree(
  { state, getters, mutations },
  {
    sendClipboard({ getters }, clipboard: string) {
      if (!accessor.connected || !getters.hosting) {
        return
      }

      $client.sendMessage(EVENT.CONTROL.CLIPBOARD, { text: clipboard })
    },

    toggle({ getters }) {
      if (!accessor.connected) {
        return
      }

      if (!getters.hosting) {
github nurdism / neko / client / src / store / index.ts View on Github external
setConnnecting(state) {
    state.connected = false
    state.connecting = true
  },

  setConnected(state, connected: boolean) {
    state.connected = connected
    state.connecting = false
    if (connected) {
      set('displayname', state.displayname)
      set('password', state.password)
    }
  },
})

export const actions = actionTree(
  { state, mutations },
  {
    initialise(store) {
      accessor.emoji.initialise()
      accessor.settings.initialise()
    },

    lock() {
      if (!accessor.connected || !accessor.user.admin) {
        return
      }

      $client.sendMessage(EVENT.ADMIN.LOCK)
    },

    unlock() {
github nurdism / neko / client / src / store / user.ts View on Github external
...member,
      },
    }
  },
  delMember(state, id: string) {
    state.members[id] = {
      ...state.members[id],
      connected: false,
    }
  },
  reset(state) {
    state.members = {}
  },
})

export const actions = actionTree(
  { state, getters, mutations },
  {
    ban({ state }, member: string | Member) {
      if (!accessor.connected || !accessor.user.admin) {
        return
      }

      if (typeof member === 'string') {
        member = state.members[member]
      }

      if (!member) {
        return
      }

      $client.sendMessage(EVENT.ADMIN.BAN, { id: member.id })
github nurdism / neko / client / src / store / client.ts View on Github external
state.tab = tab
    set('tab', tab)
  },
  setAbout(state, page: string) {
    state.about_page = page
  },
  toggleAbout(state) {
    state.about = !state.about
  },
  toggleSide(state) {
    state.side = !state.side
    set('side', state.side)
  },
})

export const actions = actionTree({ state, getters, mutations }, {})
github nurdism / neko / client / src / store / video.ts View on Github external
reset(state) {
    state.index = -1
    state.tracks = []
    state.streams = []
    state.configurations = []
    state.width = 1280
    state.height = 720
    state.rate = 30
    state.horizontal = 16
    state.vertical = 9
    state.playing = false
    state.playable = false
  },
})

export const actions = actionTree(
  { state, getters, mutations },
  {
    screenConfiguations({ state }) {
      if (!accessor.connected || !accessor.user.admin) {
        return
      }

      $client.sendMessage(EVENT.SCREEN.CONFIGURATIONS)
    },

    screenGet({ state }) {
      if (!accessor.connected) {
        return
      }

      $client.sendMessage(EVENT.SCREEN.RESOLUTION)

typed-vuex

A typed store accessor for Vuex.

MIT
Latest version published 2 years ago

Package Health Score

53 / 100
Full package analysis