Is there any way through which whatever theme a user chooses for his store, my code changes get added to that online theme and visible on the storefront side? I tried adding my code to liquid file but that changes is visible only for that theme,If i change the theme then the changes are not present there for the new theme.
The code changes should be added to whatever theme user has selected for his store.
You can try to use Asset API to add code automatically when the THEMES_PUBLISH webhook fires. However, this will be hard to implement and I am afraid this could be your only option.