Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

breaking changes since 2.0 #55

Open
beebase opened this issue Sep 14, 2023 · 0 comments
Open

breaking changes since 2.0 #55

beebase opened this issue Sep 14, 2023 · 0 comments

Comments

@beebase
Copy link

beebase commented Sep 14, 2023

Looking at the docs I see everything declared inside a .svelte file between script tags.

<script>
    import { persist, cookieStorage } from "@macfja/svelte-persistent-store"
    import { writable } from "svelte/store"
    const newsLetterSubscription = persist(writable(false), cookieStorage(), "newsletter")
</script>

Does this mean I can't use a js files anymore to define storages , attach them to a svelte store and import them into a .svelte file ?

[ < 2.0 code]
persistent.js file

import {
	persist,
	createIndexedDBStorage,
	createLocalStorage,
	createSessionStorage,
	createCookieStorage
} from '@macfja/svelte-persistent-store';
import { writable } from 'svelte/store';
import { AES, enc } from 'crypto-js';
export const idb = (sKey, value) => {
	return persist(writable(value), createIndexedDBStorage(), sKey);
};

export const local = (sKey, value) => {
	return persist(writable(value), createLocalStorage(), sKey);
};
export const session = (sKey, value) => {
	return persist(writable(value), createSessionStorage(), sKey);
};
export const cookie = (sKey, value) => {
	return persist(writable(value), createCookieStorage(), sKey);
};

logic.js

    import {local, idb} from  './persistent.js'
    export const contacts = local('array-contacts', [] );

.svelte file

<script>
import {contacts} from './logic.js'
console.log($contacts)
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant