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

Dead Repo? #98

Open
christianallred opened this issue Dec 12, 2018 · 7 comments
Open

Dead Repo? #98

christianallred opened this issue Dec 12, 2018 · 7 comments

Comments

@christianallred
Copy link

Hey there are 6 pull requests and 19 open issues that have never had responses from the author.

Is there no planned support for this repo?

@nmaves
Copy link
Collaborator

nmaves commented Dec 12, 2018

An honest question. I don't think either @svrcekmichal nor I use this library anymore. Totally willing to allow others to come on and help. I think it was built as a simple utility and it works well for what it does.

@Tralgar
Copy link

Tralgar commented Mar 22, 2019

No, you think we can use it for projects or not ? if it's not maintened, there will be deprecated dependencies... This middleware was SO cool, i dont understand why there no other repo doing this same feature. It was really clear and easy to use. Auto dispatch on success and error was cool. I'll try do it with axios only.
Or maybe someone knows an alternative ? plz @svrcekmichal come back =D

@AntonyFagundez
Copy link

Hi @svrcekmichal , this library has really been very useful to me. I would like to collaborate if possible, either to improve documentation or to add types. Please come back!

@PeterKottas
Copy link

It seems that at this point, the best way forward is to fork it and release it under a new name (with acknowledgment of course). So far, we haven't found a breaking change that we couldn't solve on the client side. But if that happens, we'll definitely be forking and fixing the issue as we have thousands of actions that conform to this API. Missing types are a pain, but it really matters mainly in the config which you rarely touch IMHO. Btw, if you look at the size of the lib, it's not like it would be too much work to replicate the functionality one way or another.

@flying-sheep
Copy link

Did anyone do this yet? It would be great to have more examples, especially how to do typing around this.

@PeterKottas
Copy link

Maybe you will find this helpful, we're happy with it.

import { AnyAction } from 'redux';

abstract class Action implements AnyAction {
  public type: string;
  // tslint:disable-next-line: variable-name
  public __proto__?: Action;
  constructor() {
    this.type = this.__proto__?.type || this.type;
  }
}

export interface ActionClass<T extends Action> {
  prototype: T;
}

export function typeName(
  name: string
): <T extends Action>(actionClass: ActionClass<T>) => void {
  return actionClass => {
    // Although we could determine the type name using actionClass.prototype.constructor.name,
    // it's dangerous to do that because minifiers may interfere with it, and then serialized state
    // might not have the expected meaning after a recompile. So we explicitly ask for a name string.
    actionClass.prototype.type = name;
  };
}

export function isActionType<T extends Action>(
  action: Action,
  actionClass: ActionClass<T>
): action is T {
  return action.type === actionClass.prototype.type;
}

// Then you define actions like this:

@typeName('SAVE_SOME_STATE')
export class SaveSomeState extends Action {
  constructor(public someValue: boolean) {
    super();
  }
}

// Reducer works like this:
export interface State {
  someValue: boolean;
}

const initialState: State = {
  someValue: false,
};

export const reducer: Reducer<State> = (state, action): State => {
  if (isActionType(action, SaveSomeState )) {
    return Object.assign({}, state, {
      someValue: action.someValue,
    } as State);
  }
  // For unrecognized actions (or in cases where actions have no effect), must return the existing state
  //  (or default initial state if none was supplied)
  return state || initialState;
};

@PeterKottas
Copy link

There's some more stuff around action creators (and thunk), but that could depend on your implementation, at least it does in our case. Especially based on how you do authorization, notifications, stuff like that.

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

No branches or pull requests

6 participants