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

Access instance Vue using this #37

Closed
IgorMCHC opened this issue May 10, 2019 · 6 comments
Closed

Access instance Vue using this #37

IgorMCHC opened this issue May 10, 2019 · 6 comments
Labels
question Further information is requested

Comments

@IgorMCHC
Copy link

image

How do I access an instance of the vue?

@ndabAP ndabAP added the question Further information is requested label May 10, 2019
@ndabAP
Copy link
Owner

ndabAP commented May 10, 2019

That's a very, very good question and something I never thought about. Unfortunately, it's not possible at the moment since data hasn't access to the instance.

The only workaround at the moment would be something like this:

<script>
import VueCommand from 'vue-command'
import 'vue-command/dist/vue-command.css'

const fn = pokemon => pokemon === 'pikachu' ? 'yellow' : `Usage: pokedex pokemon [option]<br><br>
Example: pokedex pikachu --color
`

export default {
  components: {
    VueCommand
  },

  data: () => ({
    commands: {
      pokedex: ({ color, _ }) => {
        return fn(_[1])
      }
    }
  })
}
</script>

That means your logic is independent from the instance. If you have an idea how to get access I'm happy for a contribution.

@IgorMCHC
Copy link
Author

I tried to find some method to access the instance but I did not succeed, could you inform me if you will try to update the code for this behavior?

I had a really cool idea to use with this terminal :(

@ndabAP
Copy link
Owner

ndabAP commented May 10, 2019

I think it won't be possible because the VueCommand component needs the commands at rendering time. One possibility would be that users don't return a string but a component. I already played with it but it makes the whole API much more complex.

Why isn't it possible for you to extract the logic from the instance?

@IgorMCHC
Copy link
Author

image

Because I wanted to do things like that, you know?

@ndabAP
Copy link
Owner

ndabAP commented May 10, 2019

Yeah, that's indeed reasonable. I'm sorry there is no way at the moment :(

@ndabAP
Copy link
Owner

ndabAP commented May 10, 2019

I'll create an issue for this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants