January 2, 2025
Jenkins vs GitHub Actions
I recently came across an interesting article by the team at Slack, where they share their experience migrating from Jenkins to GitHub Actions (GHA).
In the context of Vue, reactivity is the ability to track changes in data and efficiently update the user interface (UI).
When you declare reactive data, Vue turns it into reactive state and associates it with dependencies that need to be notified when that data changes.
import { reactive } from "vue";
const state = reactive({
counter: 0,
});
state.counter++;
Vue 3 uses Proxies to implement reactivity. A Proxy is a JavaScript feature that allows intercepting and redefining operations such as reading, writing, or deleting properties on an object.
const handler = {
get(target, key) {
console.log(`Accessing property ${key}`);
return target[key];
},
set(target, key, value) {
console.log(`Modifying property ${key} to ${value}`);
target[key] = value;
return true;
}
};
const reactiveObject = new Proxy({ name: "Vue", version: 3 }, handler);
console.log(reactiveObject.name);
reactiveObject.version = 4;
In Vue 3, this same principle is applied to transform objects declared with reactive or ref into reactive structures.
The reactive method converts an object into a reactive proxy. Every time you access or modify its properties, Vue records dependencies and notifies affected components.
const state = reactive({
counter: 0,
});
state.counter++;
ref is used to create simple reactive values, such as primitives or data structures that do not need to be complex objects.
import { ref } from "vue";
const count = ref(0);
count.value++;
Vue uses an internal system that tracks dependencies when reactive properties are accessed. This happens in the context of a reactive function such as computed or watchEffect.
<script setup>
import { reactive, watchEffect } from "vue";
const state = reactive({
message: "Hello, Vue!",
});
watchEffect(() => {
console.log(state.message); // This will run whenever state.message changes
});
state.message = "Reactivity in action!";
</script>
reactive or ref.For more information, you can check Vue's official documentation on Reactivity in Depth.