Skip to content

.with() chain experiment #104

@bennobuilder

Description

@bennobuilder

Chain pattern:

state.with(undoFeature(4)).with(storageFeature()).with(loggerFeature());

// or (if typesafe possible?)

state.with(undoFeature(4), storageFeature(), loggerFeature())

instead of "wrapper pattern":

withLogger(withStorage(withUndo(state, 4)));

The above referenced chain pattern might be easier to make typesafe than:

createState({
	defaultValue: 0,
	features: [withUndo(), withStorage(), withLogger()]
});

but still has better DX than the "wrapper pattern" I feel like.

or remove features completely? and name it plugins which might be more clear? but libraries are like called feature-xyz

state.use(undoPlugin(4), storagePlugin(), loggerPlugin())

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions