Skip to content

Latest commit

 

History

History
54 lines (43 loc) · 1.78 KB

File metadata and controls

54 lines (43 loc) · 1.78 KB

neutronium vue result command binding

Mixin to integrate MVVM IResultCommand with vue

Npm version MIT License Npm version

Usage

Provide mixin to easily integrate IResultCommand in vue.js using Neutronium. Component this mixin exposes:

Function

topromise(resultCommand, arg)

Executes the given resultCommand passing the sacond argument as parameter and returns a promise;

Example

To bind to C# ResultCommand property:

public class ViewModel
{
    public IResultCommand ResultCommand {get;} 
    
    public ViewModel()
    {
        ResultCommand = RelayResultCommand.Create<string, int>(Count);
    }

    private int? Count(string routeName)
    {
       return routeName?.Length;
    }
}

Do on javascript side:

import {toPromise} from 'neutronium-vue-resultcommand-topromise'

const promise = toPromise(viewModel.ResultCommand, 'countLetterNumber');
promise.then((ok)=>{
     //Ok code
 }, (error) =>{
 //Error handling
})

Installation

  • Available through:
 npm install neutronium-vue-resultcommand-topromise --save