Ramda Reactive
![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)
✅ Like vue-chemistry but with ramda functions instead
✅ Everything is still auto-curried
✅ All functions accept refs
✅ Completely typed
Why
computed | ramda-reactive |
---|
computed(() => map(inc, xs.value) | useMap(inc, xs) |
computed(() => filter(lte(5), xs.value) | useFilter(lte(5), xs) |
computed(() => foo.value || bar.value) | useOr(foo, bar) |
- no
.value
everywhere - no
computed(() =>
- less visual clutter
Examples
Simple reactive filtering
import { ref } from 'vue'
import { useFilter } from 'ramda-reactive'
import { lt, __ } from 'ramda'
const xs = ref([1, 2, 3, 4])
const below3 = useFilter(lt(__, 3), xs)
xs.value = [1, 1, 5]
xs.value.push(1)
Advanced reactive filtering
import { ref } from 'vue'
import { useFilter, useLt } from 'ramda-reactive'
import { __ } from 'ramda'
const xs = ref([1, 2, 3, 4])
const threshold = ref(4)
const lessThanThreshold = useLt(__, threshold)
const belowSomething = useFilter(lessThanThreshold, xs)
threshold.value = 3
xs.value = [0, 1, 2, 3, 4]
useCall to reactively call non reactive function
import { ref } from 'vue'
import { useCall } from 'ramda-reactive'
const add = (a, b) => a + b
const foo = ref(1)
const bar = ref(2)
const result = useCall(add, foo, bar)
foo.value = 3
Properties on reactive objects can also be used (similar to vues watch)
import { ref, reactive } from 'vue'
import { useAdd } from 'ramda-reactive'
const foo = ref(1)
const bar = reactive({ count: 2 })
const result = useAdd(foo, () => bar.count)
foo.value = 3
bar.count = 5
Author
👤 Tim Kutscha
Show your support
Give a ⭐️ if this project helped you!
📝 License
Copyright © 2023 Tim Kutscha.
This project is MIT licensed.