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

Fluid Interactors #735

Merged
merged 5 commits into from
Jan 19, 2021
Merged

Fluid Interactors #735

merged 5 commits into from
Jan 19, 2021

Conversation

jnicklas
Copy link
Collaborator

@jnicklas jnicklas commented Dec 15, 2020

This explores the design space of an alternative API for creating interactors.

See: #737

@changeset-bot
Copy link

changeset-bot bot commented Dec 15, 2020

🦋 Changeset detected

Latest commit: 052bf8f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@bigtest/interactor Minor
bigtest Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Dec 15, 2020

A preview package of this pull request has been published with the tag fluid-interactors.
You can try it out by running the following command:

$ npm install @bigtest/interactor@fluid-interactors

or by updating your package.json to:

{
  "@bigtest/interactor": "fluid-interactors"
}

Generated by 🚫 dangerJS against 052bf8f

@jnicklas jnicklas marked this pull request as ready for review January 15, 2021 16:14
@jnicklas jnicklas requested review from cowboyd and dagda1 January 15, 2021 16:16
Comment on lines +4 to +18
export function makeBuilder<T, E extends Element, F extends Filters<E>, A extends Actions<E>>(base: T, name: string, specification: InteractorSpecification<E, F, A>): T & InteractorBuilder<E, F, A> {
return Object.assign(base, {
selector: (value: string): InteractorConstructor<E, F, A> => {
return createConstructor(name, { ...specification, selector: value });
},
locator: (value: LocatorFn<E>): InteractorConstructor<E, F, A> => {
return createConstructor(name, { ...specification, locator: value });
},
filters: <FR extends Filters<E>>(filters: FR): InteractorConstructor<E, F & FR, A> => {
return createConstructor(name, { ...specification, filters: { ...specification.filters, ...filters } });
},
actions: <AR extends Actions<E>>(actions: AR): InteractorConstructor<E, F, A & AR> => {
return createConstructor(name, { ...specification, actions: Object.assign({}, specification.actions, actions) });
},
});
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once we remove backward compatibility, this will no longer need to be a separate thing

Copy link
Member

@cowboyd cowboyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should talk about what in the guides need to be updated with this new syntax. Obviously there are the 1:1 API changes, but this also changes the story around how to write your own interactor since this now enables deriving interactors from other interactors and the ability to to "extend" an existing interactor instead.

Let's update the 1:1 changes in the guides with this PR, and then we can have the discussion about what is the best way to write and organize your own interactors and your own interactor library.

/cc @minkimcello @jenweber

@jnicklas
Copy link
Collaborator Author

@cowboyd worth mentioning that as far as I am aware, this change is 100% backward compatible.

@cowboyd
Copy link
Member

cowboyd commented Jan 19, 2021

Oh snap! Well in that case we can do the documentation upgrade later

@jenweber
Copy link
Collaborator

Decoupling docs updates from this change makes sense to me. The new API experience seems great too.

@jnicklas jnicklas merged commit 3b2e15d into v0 Jan 19, 2021
@jnicklas jnicklas deleted the fluid-interactors branch January 19, 2021 15:55
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

Successfully merging this pull request may close these issues.

3 participants