levibostian / Wendy-Android

Build offline first Android mobile apps. Remove loading screens, perform tasks instantly.
https://levibostian.github.io/Wendy-Android/wendy/
MIT License
64 stars 16 forks source link

Migration for tags rename #47

Closed Grohden closed 5 years ago

Grohden commented 5 years ago

When a wendy task is created the tag is saved as a string, normally you use something like

    val TAG: String = Clazz::class.java.simpleName

But if you rename the class all current pending tasks break.. forcing you to ~cry~ clear the app data. is there any way to solve that now with wendy api? Also, this should be warned in the docs. Note: i'm using 0.2.1-alpha

levibostian commented 5 years ago

At this time, no, there is not a migration feature. There also may never be.

I have thought about this issue before and decided that a migration feature would be too complex of a solution to solve the problem.

The problem is that after you change a class's name, the tag's name is now changed and Wendy can no longer run those tasks.

The solution that I felt was the best way to solve the problem is instead of using: val TAG: String = Clazz::class.java.simpleName as the tag, use a String: val TAG: String = "Clazz". So if you ever change the name of Clazz, nothing is broken.

Thank you for the message so I can update the docs. I have been using strings in my own apps these days anyway. I like to use a description like: "Update users profile photo" as the tag. I feel that it is more universal then UploadProfilePhotoPendingTask::class.java.simpleName.

I do not see a way to remove the need for tags at this time so the best way we can solve this problem is with best practices and docs. That would be a great way to fix this.

Would you like to update the README and send a pull request? Feel free!

Grohden commented 5 years ago

@levibostian i understand, i just opened this because of the need to document it, if you release an app and rename a tag you would have some problems to fix that... but wendy error message at least make it easy to find the error <3

I'll try to make a PR, it will take some weeks till i get some time for that. Also, your suggestion to use a string should be in best practices...

Note: I'm kind of annoyed that the README syntax highlight is not configured for Kotlin, I'll fix that too

levibostian commented 5 years ago

@Grohden I agree with everything you stated.

  1. Using a descriptive string should be the best practice. Add a note to the docs that this should be the best practice.
  2. Share that the descriptive string should not change. This allows you to change the name of your PendingTask and Wendy works as expected.
  3. Add Kotlin syntax highlighting to readme 😄. Agreed!

Thanks for creating the issue. This is a fix that needs to be done.

levibostian commented 5 years ago

Closed by https://github.com/levibostian/Wendy-Android/pull/49