Giter VIP home page Giter VIP logo

vue-proxi's Issues

Request: Typescript Support

I see typescript errors when trying to use the injected props in my child component. Typescript is unable to find these injections. The code renders locally, but these typescript errors break the build of my application.

Things I've tried

  1. This works as expected, but I get this breaking typescript error
image
  1. This does not work, and gives me this typescript error. I thought this might work because this was shown in the documentation.
image

The Solution I'd Like

I would like to be able to access my props directly this.myProp or through some const to make it clear that it's injected like this.ProxiInjection.myProp without any typescript errors

Reproduction

You can explore a reproduction of this error here: https://codesandbox.io/s/vue-typescript-example-forked-x4h98x?file=/src/App.vue

comparison: Reactive Provide vs Proxi

This is a comparison between Reactive Provide and Proxi to outline differences in purpose and how one is not necessarily an alternative to the other.

Reactive Provide 0.3.0 Proxi 1.0.0-beta.1
Purpose To provide a reactive object given a list of properties from the Parent VM To proxy data applied to the <proxi> to a targeted Child component instance
Uses provide/inject โœ… โœ…
Has template API โŒ โœ…

Founded on the idea that component communication should remain in the template instead of re-invented
Passes down attrs, props, listeners attached to the Parent โœ… โœ”๏ธ

Not primariy use-case but possible with <proxi v-bind="{ ...$props, ...$attrs}" v-on="$listeners">
Parent can bind arbitrary class, attrs, props, listeners to the Child โŒ

You can pass down any property from Parent VM but won't be bound
โœ…

listeners and props automatically bound to Child, class available in this.$$.class, attrs available in this.$$.attrs
Child can pass down injected attrs and listeners โŒ

The injected data is merged into a single object. Would require filteration
โœ”๏ธ v-bind="$$.attrs" v-on="$$.listeners"
Dependents
Install size
Bundle size

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.