vuefire icon indicating copy to clipboard operation
vuefire copied to clipboard

Decorators for compatability with vuex-module-decorators

Open tommyo opened this issue 5 years ago • 8 comments

Would be great if we could do things like:


@Module
export default class Collection extends VuexModule {
  
  documents = [];

  @FirestoreAction
  bindCollection({ context }, name: string) {
    context.bindFirestoreRef('documents', db.collection(name));
    context.unbindFirestoreRef('documents');
  }
}

Would allow actions and state to be more true to how they look in Vanilla Vuex while also making them typesafe.

tommyo avatar Jun 20 '19 19:06 tommyo

vuex-module-decorators not being an official library, I don't want to directly expose the decorator on vuefire, instead we could add a page to the cookbook docs explaining how to do

posva avatar Jun 22 '19 18:06 posva

Now that I think about it, I agree - it doesn't belong in this package. I wrote a very simple vuexfire-decorators as a separate package. I'll release it as soon as it's hardened.

when combined with vuex-module-decorators and typescript, your todo example (as a module) looks like:

@Module
export default class TodoState extends VuexModule {

  public todos: Todo[] = [];

  @FirestoreBind('todos')
  public bindTodosRef() {
    return db.collection('todos');
  }
}

tommyo avatar Aug 28 '19 20:08 tommyo

I'd like to see how this is done -- @tommyo any chance you could release this or at least show a workaround?

garyo avatar Sep 18 '19 02:09 garyo

@tommyo I would also like to see this

mjcadz avatar Oct 03 '19 05:10 mjcadz

@tommyo same here!

TomKaltz avatar Nov 29 '19 17:11 TomKaltz

@tommyo, even if the workaround isn't hardened yet, sharing a loose version to implement in the meantime would be really helpful.

liamrosenfeld avatar Dec 26 '19 20:12 liamrosenfeld

@tommyo, can you share a link on how did you implement the decorator firestorebind ? Even if it is not ready for productio yet

mrzdevcore avatar Mar 21 '20 14:03 mrzdevcore

Now that I think about it, I agree - it doesn't belong in this package. I wrote a very simple vuexfire-decorators as a separate package. I'll release it as soon as it's hardened.

when combined with vuex-module-decorators and typescript, your todo example (as a module) looks like:

@Module
export default class TodoState extends VuexModule {

  public todos: Todo[] = [];

  @FirestoreBind('todos')
  public bindTodosRef() {
    return db.collection('todos');
  }
}

Looks awesome! Any update on this?

otonielguajardo avatar Aug 13 '20 16:08 otonielguajardo

Closing as decorators for vue in terms of typings are being deprecated and there hasn't been any activity.

If anybody publishes a lib, feel free to post it here

posva avatar Oct 13 '22 11:10 posva