这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@alies-dev
Copy link
Collaborator

@alies-dev alies-dev commented May 14, 2024

Closes #20

Idea: we don't need to create a custom API to manage items in Dialog::$memory, Collection implementations (e.g. Laravel Collection) already provide a way for this. We just need to make sure that existing serialised dialogs work with this new implementation.

New code example:

$this->memory->put($key, $value);
$this->memory->forget($key);
$value = $this->memory->get($key, 'defalut');
$value = $this->memory->pull($key);

Old code example:

$this->remember($key, $value);
$this->forget($key);
$value = $this->memory[$key] ?? 'defalut';

Because of these changes, we don't need Dialog::remember and Dialog::forget methods anymore. I market them as deprecated and they will be removed in the v1.0

@alies-dev alies-dev self-assigned this May 14, 2024
alies-dev added 2 commits May 14, 2024 15:14
# Conflicts:
#	composer.json
#	tests/DialogSerializationTest.php
#	tests/Fakes/FakeBot.php
#	tests/Fakes/FakeHttp.php
@lptn lptn merged commit f59636f into master May 14, 2024
@lptn lptn deleted the memory-collection branch May 14, 2024 21:24
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.

Dialog.php: add "get" from memory?

3 participants