fritx / vue-at

At.js for Vue.
https://fritx.github.io/vue-at/
MIT License
529 stars 114 forks source link

event when user press @ #102

Open faraztanveer opened 4 years ago

faraztanveer commented 4 years ago

An event when user press '@'. I want to get members list from server side so when user press @ i will update the list of members. i tried @at event as explained in this issue #16 but this event triggers whenever key is pressed.

Example: when "hello @username" is entered. event should trigger when @ is pressed and i get 'username' value only, not hello @username

fritx commented 4 years ago

@faraztanveer hey which version of vue-at do you use?

I could not reproduce it on my side (vue-at 2.5.0-beta.2), but you can also try passing <at :allow-spaces="false">, that would avoid allowing spaces included in the chunk like

# input
Hello @name foo bar

# emits
- @at chunk='n'
- @at chunk='na'
- @at chunk='nam'
- @at chunk='name'

# while with the default prop allow-spaces=true
- ...
- @at chunk='name'
- @at chunk='name '
- @at chunk='name f'
- @at chunk='name fo'
- @at chunk='name foo'
- @at chunk='name foo '
- @at chunk='name foo b'
- ...

PS: each of the above event would be triggered once or twice, which could be improved

faraztanveer commented 4 years ago

@fritx thank you 👍