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 Component.removed #1956

Closed
erickzanardo opened this issue Sep 29, 2022 · 13 comments · Fixed by #2080
Closed

Add Component.removed #1956

erickzanardo opened this issue Sep 29, 2022 · 13 comments · Fixed by #2080

Comments

@erickzanardo
Copy link
Member

Problem to solve

We need a way to subscribe/listen for a component removal.

Proposal

All Flame components already provide a mounted property that returns Future that is completed when the component is mounted on the tree.

We could follow this approach (both in concept and implementation) and implement an equivalent for a removed property.

@hey24sheep
Copy link

Dispose is unmount equivalent. Event's can be fired from overriden dispose to other subscribers.

 @override
  void dispose() {
    super.dispose();
  }

@ufrshubham
Copy link
Member

Dispose is unmount equivalent. Event's can be fired from overriden dispose to other subscribers.

It is not the same. One can hold a reference to unmounted component and mount it at a later point. Dispose is more like a destructor. Also, Component does not extent anything to override dispose from.

@hey24sheep
Copy link

I see, there is also "unmount". In my previous org, we used to dispose most component to save memory and make the app faster. So, I never looked into unmount.

Also, Component does not extent anything to override dispose from.

Could you give a file or line ref where this base abstract class resides. So, I can understand how mount and other stuff is working, I would really appreciate it. As, it is hacktober fest so I am looking to contribute.

@ufrshubham
Copy link
Member

I see, there is also "unmount". In my previous org, we used to dispose most component to save memory and make the app faster. So, I never looked into unmount.

Okay, just to make it clear, component in Flame's context means the Component class. It has nothing to do with Flutter widget and/or the state lifecycle events (maybe conceptually they do have some similarities).

Could you give a file or line ref where this base abstract class resides. So, I can understand how mount and other stuff is working, I would really appreciate it. As, it is hacktober fest so I am looking to contribute.

Code for that class can be found here. You should be able to get there using your IDE's go to definition feature. I'll also recommend taking a look at Flame's docs to get an idea of how components work in Flame.

@rivella50
Copy link
Contributor

This feature can be used to detect if a relayout is necessary for the children of the planned components ComponentRow and ComponentColumn. #1944

@ufrshubham
Copy link
Member

Hey @hey24sheep, can you confirm if you are working on this? If so @spydon or someone else can assign it to you.

@spydon
Copy link
Member

spydon commented Oct 2, 2022

I think this issue is up for grabs, hey24sheep most likely only tripped into this repo after I made a PR on one of their repos. 😄

@hey24sheep
Copy link

@ufrshubham I apologize for delayed response, keep it open for anyone. As, I can see there is already a lot of progress farther than I can make as I still do not understand clearly the problem. I can see there is a base remove function and it is being used in the new PR of LayoutComponent. I think of StreamBuilders and InheritedWidget as that's what I have used in past to update parents about children and to maintain dynamic loading of child components.

@spydon Yes, but, I contribute to Hacktoberfest and I see there are a lot of open issues with the same. So, thought of filling up my Hacktoberfest PR count 😄

@spydon
Copy link
Member

spydon commented Oct 3, 2022

@spydon Yes, but, I contribute to Hacktoberfest and I see there are a lot of open issues with the same. So, thought of filling up my Hacktoberfest PR count 😄

Makes sense. :)
Components in Flame are not widgets, that's why StreamBuilder or InheritedWidget can't be used btw.

@ufrshubham
Copy link
Member

If this issues is still free till October last week, I will take a look. Will drop a comment here when I do start working on it.

@spydon
Copy link
Member

spydon commented Oct 3, 2022

@JigneshWorld I can't assign you to this before you have commented on it. :)

@idlehart
Copy link
Contributor

idlehart commented Oct 6, 2022

I can have a look at this unless JigneshWorld is on it already :)

@spydon
Copy link
Member

spydon commented Oct 6, 2022

Since it's been 3 days and no comment from them, I'll assign you to it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants