3.1.0 • Published 3 years ago

@lumkani/view-model-api v3.1.0

Weekly downloads
47
License
MIT
Repository
github
Last release
3 years ago

View Model API

npm.io npm.io codecov npm.io

Summary

An additive way of writing Vue components with dependency injection

Installation

$ yarn add @lumkani/view-model-api
import Vue from 'vue'
import { ViewModel } from '@lumkani/view-model-api'

Vue.use(ViewModel)

Basic Example

Class-based Syntax

class TextViewModel {
  static data = () => ({
    text: null
  })
  
  static mounted = async (vm) => {
    const textData = await someAPI()
    
    vm.text = textData
  }
}

export { TextViewModel }

Object-literal syntax

const TextViewModel = {
  data: () => ({
    text: null,
  }),
  mounted: async (vm) => {
    const textData = await someAPI()
    
    vm.text = textData
  }
}

export { TextViewModel }
<template>
  <p>{{ text }}</p>
</template>

<script>
import { TextViewModel as ViewModel } from './model'

export default { ViewModel }
</script>

Motivation

Here at Lumkani, we love Vue as Vue is such an approachable frontend library or framework in some cases, but we found that if you want to test logic in a component you would need to mount the component just to test the logic and so with the ViewModel API, you can now write your logic without putting your JS in a Vue component

The benefits for the team:

  1. A solid structure
  2. Easier to test
  3. Quicker to debug
  4. Code reviews become easier
3.1.0-beta.0

3 years ago

3.1.0

3 years ago

3.0.3

4 years ago

3.0.3-beta.0

4 years ago

3.0.1-beta.3

4 years ago

3.0.1-beta.4

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.1-beta.0

4 years ago

3.0.1-beta.1

4 years ago

3.0.1-beta.2

4 years ago

3.0.0

4 years ago

3.0.0-beta.0

4 years ago

2.5.0-beta.2

4 years ago

2.5.0-beta.0

4 years ago

2.5.0-beta.1

4 years ago

2.4.1

4 years ago

2.4.0

4 years ago

2.4.0-beta-3

4 years ago

2.4.0-beta.2

4 years ago

2.4.0-beta.1

4 years ago

2.4.0-beta.0

4 years ago

2.3.0

4 years ago

2.3.0-beta.0

4 years ago

2.3.1

4 years ago

2.2.0

4 years ago

2.1.2

4 years ago

2.1.0-beta.0

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.2

4 years ago

2.0.2-beta.0

4 years ago

2.0.1-beta.0

4 years ago

2.1.1-beta.0

4 years ago

2.0.0

4 years ago

1.2.0

4 years ago

1.2.0-beta.1

4 years ago

1.2.0-beta.0

4 years ago

1.1.0

4 years ago

1.1.0-beta.0

4 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago