Aug 24, 2017 · 1 min read
Nice! You could also potentially return FragmentTransaction from your lambda extension and then have your transaction chain like it does currently
inline internal fun FragmentManager.transaction(func: FragmentTransaction.() -> FragmentTransaction) {
// Chained
beginTransaction().func().commit()
}Anyone reading may be interested to see you can do a similar thing with SharedPreferences:
inline internal fun SharedPreferences.applyMe(func: SharedPreferences.Editor.() -> SharedPreferences.Editor) {
this.edit().func().apply()
}preferences.applyMe {
putBoolean("SOMETHING", true)
}
