In this example, $derivedValue is reactive; if myArray is changed at index 3, it will change automatically, too.
App.svelte
<script>
import { myArray, derivedValue } from './store';
</script>
<h1>{$myArray}</h1>
<h1>{$derivedValue}</h1>
store.js
import {derived, writable} from 'svelte/store';
export const myArray = writable([6, 7, 8, 9, 10]);
export const derivedValue = derived(myArray, value => value[3]);
I would like to create a reactive getter, which looks like this:
export const derivedValue = index => derived(myArray, value => value[index]);
Of course, in this case derivedValue is a function and is not subscribable anymore. Is there a way to create such a subscribable reactive derived value with a parameter?