Coder Social home page Coder Social logo

mariusheine / use-feathers Goto Github PK

View Code? Open in Web Editor NEW

This project forked from geprog/use-feathers

0.0 0.0 0.0 339 KB

Vue.js compositions for Feathers

Home Page: https://www.npmjs.com/package/@geprog/use-feathers

License: MIT License

JavaScript 0.77% TypeScript 99.23%

use-feathers's Introduction

Vue.js compositions for Feathers

Provides get and find compositions that let you query your feathers API.
Queries and responses are fully reactive allowing you to:

  • trigger a query by simply updating a query parameter
  • receive continuous updates via @feathersjs/socketio-client that are instantly visible inside Vue components.

Example usage

Define a wrapper that passes your feathers app.
Passing your Application type including your ServiceTypes allows typechecking of the serviceName parameter.

// useFindWrapper.ts
import { useFind } from '@geprog/use-feathers';
import { Application as FeathersApplication } from '@feathersjs/feathers';
import { AdapterService } from '@feathersjs/adapter-commons';
import { Car } from './model';

type ServiceTypes = {
  cars: AdapterService<Car>;
};

type Application = FeathersApplication<ServiceTypes>;

export const useFindWrapper = useFind<Application>(yourFeathersApp);

Inside a Vue component call the wrapper with a serviceName and a Params ref containing your query.

import { computed, defineComponent } from 'vue';
import { useFindWrapper } from './useFindWrapper';

export default defineComponent({
  setup() {
    const seats = ref(4);
    const { data: cars, isLoading } = useFindWrapper(
      'cars',
      computed(() => ({ paginate: false, query: { seats: seats.value } })),
    );
    return { seats, cars, isLoading };
  },
});

use-feathers's People

Contributors

lukashass avatar anbraten avatar renovate[bot] avatar raphaelschwinger avatar mariusheine avatar

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.