Can I add features to an existing ionic component without creating a custom component?

I’d like to add the ability to save what the user typed in an ion-searchbox when they leave the page it’s on, and load what they entered back in when they return. Rather than have this code on every page with a searchbox, I decided to make a custom component so I would only have to write the code once.
So I made a custom component that does just that, but then I started thinking if there was an easier way to do this, like to extend the ion-searchbar or something.

Is there an easier way to add a new feature to an existing component, was my custom component solution the right one, or is there an even better solution yet?

I don’t think that solves your problem in general. Maybe in your specific situation right now. The general solution for this is to define a provider.