Skip to content
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

Use Laravel Collection for Dialog Memory #23

Merged
merged 6 commits into from
May 14, 2024
Merged

Use Laravel Collection for Dialog Memory #23

merged 6 commits into from
May 14, 2024

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
6 of 7 checks passed
@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?
2 participants