Skip to content
This repository was archived by the owner on Jan 25, 2021. It is now read-only.
This repository was archived by the owner on Jan 25, 2021. It is now read-only.

Factories are un-ergonomic #6

Description

@domenic

When I think of a factory in JavaScript, I think of a function, not an object with a .get() method. This becomes particularly inconvenient when trying to pass factories around.

For example, when moving to Intravenous, my code went from

function Foo(barFactory) {
    this.doSomething = function () {
        return processSomeBars(barFactory);
    };
}

to

function Foo(barFactory) {
    this.doSomething = function () {
        return processSomeBars(barFactory.get.bind(barFactory));
    };
}

I think the solution would be to just make factories into functions. They can still have .get, .use, .dispose, and the like, but calling the factory as a function should have the same result as calling .get.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions