Code Monkey home page Code Monkey logo

vuex-connect's People

Contributors

aggre avatar bmaland avatar dependabot-preview[bot] avatar dependabot[bot] avatar greenkeeperio-bot avatar ktsn avatar matt-oconnell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

vuex-connect's Issues

Typescript typings

Would you have time to make some typescript definitions for this library?

Or an example of how to use this with typescript? I see the actual source is built using typescript.

Use with .vue files

Hello!

I'm having problems using this with .vue files, is there a way you know of to work around this? What seems to be happening is that vue-loader replaces the render function set by insertRenderer.

Dynamically update the connected store based on route

Hi! I'm making a searchbar and using this library to connect it to a search store. The problem I'm running into is that I need to be able to dynamically switch the store the component is connected to based on the route the user is on, as they can perform different types of searches on different routes using the same searchbar.

My connected searchbar component looks like this:

import { connect } from 'vuex-connect';
import Searchbar from './searchbar';

export default param => connect({
  gettersToProps: {
    searchCriteria: `${param ? `${param}/` : ''}criteria`
  },

  actionsToEvents: {
    'search-updated': `${param ? `${param}/` : ''}updateSearch`
  }
})('Searchbar', Searchbar);

That way in the component I'm adding it to I can do this:

<template>
...
</template>
<script>
  import Searchbar from 'components/searchbar/searchbar-connect';
  export default {
    components: {
      Searchbar: Searchbar('search')
    }
  ...
  }
</script>
<style>
...
</style>

Is there a way to do what I'm trying to do that you know of?

Component instance during connection

Currently this refers to the component that we are connecting, not the actual component that is hosting it.

example:

import { connect } from 'vuex-connect'
import Foo from '@/components/Foo'

export default {
  name: 'Bar',

  props: {
    id: {
      type: Number,
      required: true
    }
  },

  components: {
    Foo: connect({
      methodsToEvents: {
        save ({ dispatch }, values) {
          dispatch('saveUserData', {
            data: values,
            id: this.id // This is not possible
          })
        }
      }
    })('foo', Foo)
  }
}

Would make sense to be able to pass data from the component instance inside the connect method.

In this example we can't pass the id property of the current component because the context refers to the actual Foo component

Thanks for your time

Cheers

named slot content gets put into default slot

Given a component such as:
TestComponent.vue
<template> <ul> <li><slot>Default Slot</slot></li> <li><slot name="test">Test Slot</slot></li> </ul> </template>

And using the component:
App.vue
<test-component> <span>This should go in default slot</span> <span slot="test">This should go in test slot</span> </test-component>

If I give TestComponent a connector, all slotted elements (whether they specify a slot name or not) get pushed into the default slot. If I remove the connector, it works properly.

I have a small reproduce-able app here
https://github.com/devinholloway/named-slot-passthrough-connector

Vue 3 compatibility

vuex-connect seems incompatible with Vue 3. I discovered those issues so far:

  • no default Vue import (currently used for Vue.extend, which has been removed)
  • render function doesn't provide h anymore, needs to be imported from vue
  • render function props flattened
  • lifecycle destroyed renamed to unmounted, beforeDestroy -> beforeUnmount
  • $listeners removed
  • $scopedSlots removed

Do you have plans to release a new version for Vue 3?

Connected component is no able to use events

The component we are connecting to the Vuex store, because it's wrapped with the vuex-connect, is not able to communicate with its parent via events.

As described in this section of the documentation, could be possible to just pass all listeners down using v-on="$listeners"

Thanks for your time

how do you add a method to a component?

thanks for the great work. it's awesome for someone coming from reactjs. I need to be able to connect methods to a component. How do you do that with vuex-connect?

[Feature Request] Support better vue-router integration

Hi. Thanks for the useful library!

However, I noticed that the wrapped component that vuex-connect generate has some drawbacks when trying to use with vue-router. Do you have any plan to improve the integration with vue-router?

1. In-component guards hooks

These component hooks are used by vue-router, but currently no way to declare them.

  • beforeRouteEnter
  • beforeRouteUpdate
  • beforeRouteLeave

https://router.vuejs.org/en/advanced/navigation-guards.html#in-component-guards

2. Declaring props for accepting router's parameters

Props are used to pass parameters from 'vue-router`.

Slots not working in wrapped component

When specifying slots (named or unnamed) in a vuex-connect component, the slot values aren't being applied.

When importing the base component, the page shows the custom slot content as you'd expect. When importing the wrapped component, the default slot content appears.

I've got a minimal demonstration of this here. The slot content is being customized in App.vue.

Support for Vuex 3.0.0

Seems to be working fine except for a warning:

WARN [email protected] requires a peer of vuex@^2.0.0-rc but none is installed. You must install peer dependencies yourself.

Can we update the peer dependency to

'>= 2.0.0'

You would know better if there are any issues with doing that.

Thanks

Only the first prop gets pushed to the wrapped component.

I have a route defined as:
{
path: '/batches/:batchId/books/:bookId',
name: 'Book',
component: BookContainer,
props: true
}

BookContainer is a vuex-connect component wrapping Book component.

Notice I have props:true, which should pass both batchId and bookId as props to BookContainer (which should pass them on to Book.

I've defined both props in Book:

props: {
batchId: {
type: String,
required: true
},
bookId: {
type: String,
required: true
}
}

I visit '/batches/1/books/2' and batchId is correctly set but bookId is always undefined.

Wrapper Mixins / Keeping Wrappers DRY

Hi there,

I have a lot of wrappers which will need the same set of connect mappings. I'm wondering if the library provides a way to keep this DRY or if I should just store the mappings in a const somewhere and import it whenever I need the set of wrapper mappings that go together? I'm wondering if maybe there is some kind of mixin or something I can leverage in the wrappers.

Thanks for the great library and any guidance is appreciated.

Access 'this' scope of wrapped component when using createConnect

Not sure if this is a bug, or I just can't figure out how to do it...

Normally, in a connector, I can access the 'this' scope of the component I'm wrapping. However, when using createConnect in order to implement route lifecycle methods, I seem to lose access to 'this'. For example:

beforeRouteLeave(store, to, from, next) {
const someData = this.someData
// undefined even though someData exists
// on the wrapped component's data() model.
}

Is there something additional I need to do?

Connect dynamic module to component based on prop

I am quite skeptical something like this should be possible:

stateToProps: {
  data: (state, component) => state.articles[component.id].data
},

However, is there some way to connect a component to a module based on a namespace that has been provided to the component some way?

I found a similar issue vuejs/vuex#863, which seems related, and in which vuex-connect is mentioned.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.