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

[Question] $fineMq reactive prop undefined / Register .on callback with plugin #8

Open
Jones-S opened this issue Aug 4, 2021 · 2 comments

Comments

@Jones-S
Copy link

Jones-S commented Aug 4, 2021

  • I'm submitting a ...
    [x] question about how to use this project

  • Summary
    The Readme tells me that I have the following three instances available:

// Three reactive properties will then be available on Vue instances:
// - $mq is an object that contains the matching state for each alias in the form { [alias]: true/false }.
// - $lastActiveAlias will contain the last alias that was matched and triggered by the listener.
// - $fineMq is a FineMq instance for advanced usages.

Now I can access
context.root.$mq and context.root.$lastActiveAlias but I can't access
context.root.$fineMq because this is undefined.

I am using fineMq as a plugin and I would like to register an .on callback, now I don't really know how I could register that..

import Vue from 'vue'
import FineMq from 'fine-mq'

Vue.use(FineMq, {
  aliases: {
    mobile: 574,
    tablet: [575, 1024],
    mobilefooter: 1024,
    desktop: [1025, 1279],
    mobilenav: 1279,
    widescreen: [1280, 1365],
    ipadpro: [1366],
    landscape: '(orientation: landscape)'
  }

And than later on within a composable of my composition api I would like to register this .on callback, but I don't know how to achieve that.

Help is very welcome. Thank you in advance.

Cheers

@Jones-S Jones-S changed the title $fineMq reactive prop undefined / Register .on callback with plugin [Question] $fineMq reactive prop undefined / Register .on callback with plugin Aug 4, 2021
@nash403
Copy link
Owner

nash403 commented Aug 11, 2021

Hi !

Sorry for late answer I am currently on vacation.

I noticed a few days ago that my plugin has issues when used with the composition api.

I guess the difference here comes from how $fineMq is injected (on the Vue instance prototype) in opposition to how $mq and $lastActiveAlias are injected (as computed mixins).

You'll also notice that $mq is not reactive inside the setup function (if you use it for a computed or a watcher for ex) but it is in the template or in computed option.

I'll investigate more when I return from vacation and try release a fix for those issues.

@Jones-S
Copy link
Author

Jones-S commented Nov 15, 2022

Hey @nash403
Could you find some solution for this?
I need to update vue and I would like to use the built in composition api in vue 2.7+. And now context.root is even undefined. So I cannot use context.root.$mq anymore.

I would be extremly happy if you could help me out here.

Best

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