ngrx-auto-entity icon indicating copy to clipboard operation
ngrx-auto-entity copied to clipboard

Code Duplication

Open colesanders opened this issue 4 years ago • 3 comments

When extending the base facade you're required to provide a constructor along the lines of:

export EntityFacade extends EntityFacadeBase {
    constructor(private store: Store) {
        super(Entity, store);
    }
}

However, as the base facade comes from the buildState() call, it seems to be a pointless extra. The entity could instead be provided to the facade through the buildFacade() factory.

colesanders avatar Nov 06 '21 04:11 colesanders

@colesanders I think you have a good point and I like this idea. I'm pretty sure it could be accomplished easily (see https://github.com/briebug/ngrx-auto-entity/commit/a2772e06db2cadb11fa711e22ddbcf64f4e4ff8d), but I don't think we'd be able to maintain backward compatibility. It'd break any apps using the old syntax (see https://github.com/briebug/ngrx-auto-entity/commit/72c0a9151ba2815489e6cb59a515f7b2074a1d7e)

I didn't thoroughly test that branch, because I'm guessing we won't move forward due to wanting to maintain backward compatibility. Maybe @jrista can weigh in

Wells-Codes avatar Nov 29 '21 17:11 Wells-Codes

@Wells-Codes I chatted with @colesanders about it a bit. I am concerned about backwards compatibility, however we may be able to accomplish it with overloaded constructors. I haven't tried that yet, so we will have to see if it works.

jrista avatar Nov 29 '21 17:11 jrista

It looks like there is no way to do overloaded constructors with TS. It would be nice to make this change, and it looks like @Wells-Codes started a branch for it. It might be best to time this change when we may have to make other breaking changes, which should happen soon when we support Angular 13 (and probably 14). We will have to make breaking changes at that point, and I think we could make this change then.

jrista avatar Feb 19 '22 01:02 jrista