0.1.1 • Published 5 years ago
nuro-computed-properties v0.1.1
nuro-computed-properties
A plugin for Nuro that allows you to easily create computed proprties that won't re-compute for the same inputs
Install
npm install nuro-computed-propertiesor
<script src="path/to/nuro-computed-properties.js"></script>Usage
First install NuroComputedProperties as a plugin
import { NuroComputedProperties } from 'nuro-computed-properties'
Nuro.install(NuroComputedProperties)Then create a computed property in your beforeMount hook
class App {
first = 'John'
last = 'Smith'
$template = `
<div>
{{ fullName() }}
</div>
`
beforeMount() {
this.fullName = this.$computed(function() {
return 'Mr. ' + this.last + ', ' + this.first
})
}
}Now the fullName value will only be calculated once for 'John' and 'Smith' even on subsequent renders. But if first is changed to 'Joseph' then the compute function will run again.
0.1.1
5 years ago