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

onMount doesn't work with deepMap #263

Open
motleydev opened this issue Dec 21, 2023 · 5 comments
Open

onMount doesn't work with deepMap #263

motleydev opened this issue Dec 21, 2023 · 5 comments

Comments

@motleydev
Copy link

From my observation, you can't onMount listen to a deepMap store. Is that intended?

@ai
Copy link
Member

ai commented Dec 21, 2023

No. Can you give us more details. What did you try and what you get.

@motleydev
Copy link
Author

Two identical stores:

export interface AudioPlayer {
  current: PlaylistItem | null;
  playing: Boolean;
  playlist: PlaylistItem[];
  [key: string]: any;
}

export const $audioPlayer = map<AudioPlayer>({
  current: null,
  playing: false,
  playlist: [],
});

and

export interface AudioPlayer {
  current: PlaylistItem | null;
  playing: Boolean;
  playlist: PlaylistItem[];
  [key: string]: any;
}

export const $audioPlayer = deepMap<AudioPlayer>({
  current: null,
  playing: false,
  playlist: [],
});

passed to an onMount handler. When it's map, it works as expected, when deepMap, there's no effect, no console log, etc.

@ai
Copy link
Member

ai commented Dec 22, 2023

Show how do you use onMount and how do you subscribe to the store.

@motleydev
Copy link
Author

Sorry, I use Preact useStore with Astro and I've since removed the code, but it was something like this:

onMount($audioPlayer, () => {
  console.log("doing work");
  return () => {
    // Disabled mode
  }
})

@ai
Copy link
Member

ai commented Dec 22, 2023

cc @dkzlv

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

2 participants