-
-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Use store to set current resource
- Loading branch information
1 parent
0230235
commit 7ac6de6
Showing
3 changed files
with
38 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,38 @@ | ||
<script lang="ts"> | ||
import { currentResource } from '../../store/stores'; | ||
import { fetchNui } from '../../utils/fetchNui'; | ||
import { onMount } from 'svelte'; | ||
export let params: { wild: string }; | ||
interface Data { | ||
[key: string]: number[]; | ||
} | ||
let queryData: number[]; | ||
let resource: string; | ||
const debugQueries: Data = { | ||
['luke_garages']: [300, 200, 100], | ||
['npwd']: [600, 300, 723], | ||
['ox_inventory']: [30, 270, 350], | ||
}; | ||
onMount(() => currentResource.set(params.wild)); | ||
currentResource.subscribe((value) => { | ||
resource = value; | ||
fetchNui('getResourceData', resource) | ||
.then((retData) => { | ||
queryData = retData; | ||
}) | ||
.catch((e) => { | ||
queryData = debugQueries[resource]; | ||
}); | ||
}); | ||
</script> | ||
|
||
<div>{params.wild}</div> | ||
<div> | ||
{resource} | ||
{queryData} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { writable } from "svelte/store"; | ||
|
||
export const visibility = writable(false); | ||
export const visibility = writable(false); | ||
export const currentResource = writable(''); |