-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
Since 4.4.0 Markwon instance is no longer immutable #264
Comments
Hello @KirkBushman , It is weird because there are no changes to As for class MarkwonCache {
companion object {
private val cache = Collections.synchronizedMap(WeakHashMap<Context, Markwon>())
fun with(context: Context): Markwon {
return cache[context] ?: {
Markwon.builder(context)
.usePlugin(StrikethroughPlugin.create())
.build()
.also {
cache[context] = it
}
}.invoke()
}
}
} You could also use |
I know, Looking at the code, the error will trigger when the hash is different between rebuilds. As for the Glide approach, I don't like the annotation processor and the weight it generates in general, I don't know if I like having a lot of instances of Markwon around, since binding to the view context will create an instance per comment. Having a static singleton with application context will not work with multiple modules, since you cannot reach it in the sub modules. (without disgusting code). Can you think of any other approach, that will work in most situations? |
Would you mind @KirkBushman sharing Epoxy-related code with Markwon that is causing the exception? I think we have a better chance of fixing this issue by looking at the root cause of it. Meanwhile,
The thing is - there will be exactly one instance of Markwon per activity. Individual widgets do not create own Context
If you define your singleton or a static cache in your base module (other modules depend on it) you should not have any disgusting code at all. You also can use dependency injection to provide a |
Forgot that, you're right.
You would want initialize in your application class, using app context, to map it in the core module, one should have to use an interface to implement. That would be wank code to me. Codewise, there is not a lot to look at:
|
Hello @KirkBushman , I'm going to close this as I couldn't find |
Ok, |
Markwon version: 4.4.0
Hi, I'm back.
I'm using Epoxy to manage lists and specifically collection of comments.
Since I need the markwon instance to set the content with
markwon.setParsedMarkdown
, I need to pass it to the model.By rule all params need to be immutable, to be used as a hash.
Since 4.3.1 everything was fine, upgrading to 4.4.0 I'm getting an exception on the Markwon instance, saying it's changing. ImmutableModelException.
Comparing the 2 releases I don't see anything that could be responsible for this (if it's not in the plugins...?).
May I suggest in the future an approach similar to Glide, where it can be configured at startup with a class and an annotation, and can be called anywhere with
Glide.with(context)
, avoiding the need to pass around an instance?Or having a way not needing a instance to set the content on a TextView?
I can stay on 4.3.1 with no problem for a while, just trying to start a discussion.
The text was updated successfully, but these errors were encountered: