Skip to content

Instantly share code, notes, and snippets.

@trafium
trafium / ExampleComponentRefsOnly.vue
Last active February 7, 2023 16:41
Vue composition api example (using only refs)
<template lang="pug">
div.component(ref="elRef" :style="{ filter: `saturate(${saturation}) brightness(${brightness})` }")
div
div Brightness: {{brightness}}
div Saturation: {{saturation}}
div Width: {{width}}
div Height: {{height}}
div X: {{x}}
div Y: {{y}}
</template>
/*
* Monad is a container with some value and ability to perform mapping operation
* on that value while returning result wrapped in a new Monad
*/
const Monad = value => ({
// Return mapped (transformed via passed func) value
flatMap: func => func(value),
// Return mapped (transformed via passed func) value wrapped in new Monad