Skip to content

hw-8#8

Open
rinstance wants to merge 1 commit intomasterfrom
hw-8
Open

hw-8#8
rinstance wants to merge 1 commit intomasterfrom
hw-8

Conversation

@rinstance
Copy link
Copy Markdown
Owner

No description provided.

button_save.setOnClickListener {
if (id == -1) {
val task = Task(edit_title.text.toString(), edit_desc.text.toString())
launch(coroutineContext) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

мог и не указывать, он по дефотлу его взял бы


class TaskPresenter : CoroutineScope {
private val taskRepository = TaskRepository()
override val coroutineContext: CoroutineContext
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

У тебя только один корутин скоуп. Можно его или в презентере делать или в активити. Но не 2 сразу

private lateinit var taskAdapter: TaskAdapter
private val REQUEST_CODE = 1
private val presenter = TaskPresenter()
override val coroutineContext: CoroutineContext
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coroutineContext не чистится

get() = SupervisorJob() + Dispatchers.IO

suspend fun getTaskList(): List<Task> =
withContext(coroutineContext) { taskRepository.getTasks() }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ты мог тут написать просто withContext(Dispatchers.IO), а скоуп был бы один, и активити из своего скоупа вызывал бы презентер, а так получается 2 скоупа, что не то

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants