Skip to content

Instantly share code, notes, and snippets.

View belyas's full-sized avatar
🏠
Working from home

yassine belkaid belyas

🏠
Working from home
View GitHub Profile
@belyas
belyas / signals.js
Last active February 24, 2026 10:39
Mental-model implementation of Signals in Javascript
// A global variable to track the currently running effect
let currentEffect = null;
function createSignal(initialValue) {
let value = initialValue;
const subscribers = new Set();
return {
get value() {
// 1. Dependency Tracking: If an effect is running, subscribe it!
@belyas
belyas / App.vue
Created April 21, 2023 14:40 — forked from ErikCH/App.vue
App.vue for Renderless Component Video
<script lang="ts" setup>
import FetchJson from "./components/fetch-json.vue";
// import { useFetch } from "@vueuse/core";
const url = "https://api.thecatapi.com/v1/images/search";
// const { isFetching: loading, error, data: response } = useFetch(url).json();
</script>
<template>
<h3>Random Cat Pics!</h3>
<script setup lang="ts">
import { ref, useSlots, getCurrentInstance } from "vue";
const props = defineProps<{ url: string }>();
const slots = useSlots();
let res = ref("");
let loading = ref(true);
fetch(props.url)