dsuryd / dotNetify

Simple, lightweight, yet powerful way to build real-time web apps.
https://dotnetify.net
Other
1.17k stars 164 forks source link

Extending Component Shortland #166

Closed SauliusB closed 5 years ago

SauliusB commented 5 years ago

I like the idea of Component shorthand which reduces verbosity a bit. But I just wonder possible ways to extend Vue object properties like data and created functions. Because currently using them will broke component. Is it possible to use this.super() or are there other ways? Thanks.

dsuryd commented 5 years ago

You can replace the first argument with a Vue object:

dotnetify.vue.component({
   name: 'hello-world',
   created: function() { ... }
}, 'HelloWorldVM');
SauliusB commented 5 years ago

Yes I saw that. Thanks. But when I try to add created function it never connects to backend ViewModel. My guess because it overrides components inner function with this.vm = dotnetify.vue.connect("HelloWorld", this);. If I add this line Greetings and ServerTime no more exposed in state but directly inside VueComponent. And that forces me to implement data function with all properties. That breaks the idea to keep server props inside state so no need to declare them in data function.

dsuryd commented 5 years ago

That component shorthand simply returns a Vue object. You can further manipulate that object to insert your own custom code.

SauliusB commented 5 years ago

Thanks, @dsuryd. I think this new object overrides inner one, I'd like just extend it's functionality without breaking original. Ok I will look more into this. Thanks.