wobsoriano / vue-clerk

Unofficial Vue + Clerk integration.
https://vue-clerk.com
MIT License
108 stars 8 forks source link

Reactivity issue? #15

Closed Tigran-Harutyunyan closed 5 months ago

Tigran-Harutyunyan commented 5 months ago

It seems I have reactivity issues. Excuse me if it is not intended by design.

Have a container component with "OrganizationSwitcher" component inside. It switches the organizations perfectly well, but it does not provide any events on changes.

In another component I just want to listen to current organization switch changes.

In Component 2:

const { organization } = useClerk();

this "organization" is not reactive.

I don`t know how to listen to changes. Computed props or deep watches are not triggering. DOM element listening sound stupid. only SetInterval allows to get the up to date info.

const clerk = useClerk();

setInterval(() => {
   if (clerk?.organization) {
   ...do whatever with update
  }
}, 1000);

Maybe I don't understand it well.

Thanks for package and efforts.

wobsoriano commented 5 months ago

Hi, clerk from useClerk is not reactive, it just returns an instance of the Clerk class. If you want a reactive state you can use derivedState from useClerkProvide for now:

const { derivedState } = useClerkProvide()

// derivedState.organization
Tigran-Harutyunyan commented 5 months ago

Hi, clerk from useClerk is not reactive, it just returns an instance of the Clerk class. If you want a reactive state you can use derivedState from useClerkProvide for now:

const { derivedState } = useClerkProvide()

// derivedState.organization

Thank you so much for your hint and implementation details. Really helpful. Great job! I wish someone could adapt Convex for Nuxt.

Tigran-Harutyunyan commented 5 months ago

Any plans for "OrganizationList" component? https://clerk.com/docs/components/organization/organization-list

wobsoriano commented 5 months ago

Any plans for "OrganizationList" component? clerk.com/docs/components/organization/organization-list

https://github.com/wobsoriano/vue-clerk/pull/16