Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

adding custom methods #18

@jasonvillalon

Description

@jasonvillalon

Hi,

can we add feature for adding custom methods that does not communicate with the server?

for example, right now. my work arround is to edit the feathers-redux and add something like this for me to achieve what i need.

custom/posts.js - for custom methods in post

import _ from 'lodash';

const SERVICES_POSTS_EDIT = 'SERVICES_POSTS_EDIT';
export default [
  {
    name: 'edit',
    createAction: () => id => ({ id }),
    reducer: { [SERVICES_POSTS_EDIT]: (state, action) => {
      const postIndex = _.findIndex(state.queryResult.data, { id: action.payload.id });
      const queryResult = state.queryResult;
      queryResult.data[postIndex].isEditing = true;
      return {
        ...state,
        queryResult,
      };
    },
    },
  },
];

then in when reduxifying the services i added the custom methods

import posts from './custom/posts.js';
export const feathersServices = reduxifyServices(app, mapServicePathsToNames, {}, {
  posts,
});

just to call something like this on my component

onEdit: (id) => {
    dispatch(feathersServices.posts.edit(id));
  },

maybe we can add some feature like this? not sure if good idea. but i think someone like me needed it.

Best Regards,
Jason Villalon

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions