Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue Support #49

Closed
joshua1 opened this issue Oct 6, 2017 · 14 comments
Closed

Vue Support #49

joshua1 opened this issue Oct 6, 2017 · 14 comments

Comments

@joshua1
Copy link

joshua1 commented Oct 6, 2017

Hi @dsuryd ,
Any chance you would support Vue.js ? the lib seems to be dependent on jQuery. any chance that dependency be optional?

@dsuryd
Copy link
Owner

dsuryd commented Oct 6, 2017

Vue is on the radar; priority depends on whether there's enough interest. Meanwhile, see issue #30 for possible workaround.

Starting from v2.0.6 beta, dotnetify-react already has optional dependency to full jQuery and depends only on jquery-deferred. In the absence of jQuery, it will use the included jquery-shim.

@joshua1
Copy link
Author

joshua1 commented Oct 6, 2017

@dsuryd Thanks for the response, there definitely will be enough interest if there isnt enough already. i will look at #30.

@desarrollo03TR
Copy link

desarrollo03TR commented Oct 29, 2017

Vue is really good, it would be nice to have vue support.

I guess we can connect a vm to Vue this way:

let myState = {};

new Vue({
	el: '#app',
	data: {
		vm: dotnetify.connect("MyVM", { 
                     getState: () => myState,
                     setState: newState => Object.assign(myState, newState)
                }),
        },
})

Well, it "works", but with a lot of errors in the console. I guess dotnetify is waiting some response from the JavaScript side.

$vm0.vm.State().MyMessage

The output is right (MyMessage is a property from the ViewModel).

@stevehayles
Copy link

Nowhere to vote as such, but wanted to add a big 'thumbs up' to any potential Vue integration.

Lots of similarities between Vue and React and the discussions and arguments could go on forever but Vue has a very quick learning curve and is easier to port applications built on similar 'template' style frameworks like Angular.

@dsuryd
Copy link
Owner

dsuryd commented Jan 25, 2018

I haven't learned Vue yet, but if there's anyone with Vue experience willing to collaborate, we can get this started. I will need your help creating the equivalent of WebApplication.React but with .vue files and vue material UI.

@desarrollo03TR
Copy link

I'll try to implement something.

@desarrollo03TR
Copy link

desarrollo03TR commented Apr 26, 2018

I think this can help. You can add reactive properties to a Vue instance (a Vue instance is like the main react component) after creation.

For example, this Vue instance:

new Vue({
  el: '#app1',
  data: {
	message: 'Hello world',
        age: 23,
  }
})

Can be re-created this way:

new Vue({
  el: '#app2',
  data: {
	vm: {}
  },
 created: function() {
 	this.$set(this.vm, 'message', 'Hello world');
 	this.$set(this.vm, 'age', 23);
 }
})

The this.$set function can add reactive properties to the Vue instance.

You can try with this html code:

<script src="https://cdn.jsdelivr.net/vue/latest/vue.js"></script>

<div id="app1">
  <div>
	<div>Message: {{ message }}</div>
	<input v-model="message">
	<div>Age: {{ age }}</div>
  </div>
</div>

<div id="app2">
  <div>
	<div>Message: {{ vm.message }}</div>
	<input v-model="vm.message">
	<div>Age: {{ vm.age }}</div>
  </div>
</div>

@desarrollo03TR
Copy link

desarrollo03TR commented Apr 26, 2018

Well, it works. From the Hello world demo:

Mensaje: Hello World!
Server Time: 2018-04-26T17:08:28.1936979-06:00
{
  "vm": {
  "state": {
      "$vmId": "HelloWorld",
      "$component": null,
      "$requested": true,
      "$loaded": true,
      "$itemKey": {},
      "User": {
        "Name": "World"
      },
      "Greetings": "Hello World!",
      "ServerTime": "2018-04-26T17:08:28.1936979-06:00"
    }
  }
}

The js file:

import Vue from 'vue/dist/vue.js';
import dotnetify from 'dotnetify';

new Vue({
    el: '#app',
    data: {
        vm: {},
        state: {}
    },
    created: function () {
        this.vm = dotnetify.connect("HelloWorld", {
            getState: () => this.state,
            setState: newState => {
                Object.assign(this.vm, newState);
                this.$set(this.state, 'Greetings', this.vm['Greetings']);
                this.$set(this.state, 'ServerTime', this.vm['ServerTime']);
            }
        })
    },
    beforeDestroy: function () {
        vm.$destroy();    
    }
})

But the server time property is not updating.

EDIT: It is updating now :) I think that I can create the WebApplication.Vue.

@westonsoftware
Copy link

Very interesting, I'd like to try the same thing with Vue, any progress on this? (I really don't know much React but I did do some Vue recently)

@jaredthirsk
Copy link

Hi, it has been a couple of months since last comment -- wondering if anyone has started work on this. I'm leading my .NET team into Vue because of its ease of (incremental) adoption and dotNetify could also be a good fit.

Vue stack that I love, FWIW: Vue Vuex Quasar. I wonder if Vuex would make any sense for dotNetify -- anyone have thoughts?

@westonsoftware
Copy link

westonsoftware commented Jul 29, 2018

Hi, I just spent the last week learning Quasar + Vuex and I think it's pretty awesome. I could see doing something like "quasar new store 'controller' " and then figuring out how to dotnetify that. Worth looking into at least.

@DotNetDevlll
Copy link

DotNetDevlll commented Sep 17, 2018

Noticed its moved to the planned state on the roadmap, Dsuryd thank you :)
Looking forward vue support!

There is any chance to be supported at this year?

@dsuryd
Copy link
Owner

dsuryd commented Sep 17, 2018

Thank you, the target is sometime next month.

@dsuryd
Copy link
Owner

dsuryd commented Oct 25, 2018

Vue support is provided starting v3.2.

@dsuryd dsuryd closed this as completed Oct 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants