📜  苗条的反应式异步 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:16.534000             🧑  作者: Mango

代码示例1
let package_name = 'svelte';
let download_count = 0;
$: fetch('https://api.npmjs.org/downloads/point/last-week/' + package_name)
    .then(response => response.json())
    .then(data => download_count = data.downloads || 0);

// Updating `package_name` will asynchronously update `download_count`