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

Add a withMountOnInteraction decorator #192

Open
titouanmathis opened this issue Jan 20, 2022 · 6 comments
Open

Add a withMountOnInteraction decorator #192

titouanmathis opened this issue Jan 20, 2022 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@titouanmathis
Copy link
Contributor

Or maybe a withKeepUnmounted() decorator to be able to use components and mount them programatically when needed.

@titouanmathis titouanmathis added the enhancement New feature or request label Jan 17, 2023
@antoine4livre
Copy link
Contributor

antoine4livre commented Nov 30, 2023

@titouanmathis Maybe can we just use a config param who is enabled by default ?

@titouanmathis
Copy link
Contributor Author

Do you have an API in mind for surch a configuration?

@antoine4livre
Copy link
Contributor

antoine4livre commented Dec 5, 2023

import { Base } from '@studiometa/js-toolkit';

export class UnmountedBase extends Base {
  static config = {
    name: 'UnmountedBase',
    inert: true,
  }
}

@titouanmathis
Copy link
Contributor Author

I actually prefer decorators for such specific needs which might not benefit most use cases for 2 reasons:

  • to keep the size of the Base class as small as possible
  • to avoid adding too much complexity to the Base class internals and keep them maintenable

I think it would be more easily implemented in a decorator as well as we could simply override the $mount method to add a parameter which would allow the component to be mounted.

@antoine4livre
Copy link
Contributor

Thank you @titouanmathis, so what's the final spec for this decorator ?
We need to block the first mount only or all until we authorize it ?

Would you like something like this:

$mount(force) {
  if(!force) {
    return;
  }
  super.$mount();
}

Or maybe like this:

mountIsEnabled = false;

$mount() {
  if(!mountIsEnabled) {
    this.mountIsEnabled = true;
    return;
  }
  super.$mount();
}

Have you an example of a programmed mounting ?

@antoine4livre
Copy link
Contributor

I'm going to add the decorator withKeepUnmounted that will have a boolean option named enabled that will be watched. Ok for you @titouanmathis ?

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

No branches or pull requests

2 participants