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

browser support #2

Open
Diaapi opened this issue Jun 28, 2024 · 6 comments
Open

browser support #2

Diaapi opened this issue Jun 28, 2024 · 6 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@Diaapi
Copy link

Diaapi commented Jun 28, 2024

I was testing this package and it works for me on desktop and Android but it still doesn't work for me in the browser. Could it be improved on this platform or is there an update being made?

@sandreas
Copy link
Owner

Could it be improved on this platform or is there an update being made?

Thank you for using the package and your suggestion. Unfortunately I did not find an easy way to support browsers, but I'm not that familiar with WASM integration yet. I'll keep this issue open, in case anyone wants to submit a PR or provide technical details on how to implement this.

@sandreas sandreas added enhancement New feature or request help wanted Extra attention is needed labels Jun 28, 2024
@Diaapi
Copy link
Author

Diaapi commented Jun 28, 2024

Yes, of course, I love this package, I just need support for the web.

@sandreas
Copy link
Owner

sandreas commented Feb 7, 2025

I'm on it. Discussion here, questsions answered. I probably will deprecate this package and Relaunch it as Avalonia.SimplePreferences(along to Avalonia.SimpleRouter) to match the MAUI Preferences Interface - and in addition async methods in IAsyncPreferences : IPreferences:

public interface IPreferences
{
	/// <summary>
	/// Checks for the existence of a given key.
	/// </summary>
	/// <param name="key">The key to check.</param>
	/// <param name="sharedName">Shared container name.</param>
	/// <returns><see langword="true"/> if the key exists in the preferences, otherwise <see langword="false"/>.</returns>
	bool ContainsKey(string key, string? sharedName = null);

	/// <summary>
	/// Removes a key and its associated value if it exists.
	/// </summary>
	/// <param name="key">The key to remove.</param>
	/// <param name="sharedName">Shared container name.</param>
	void Remove(string key, string? sharedName = null);

	/// <summary>
	/// Clears all keys and values.
	/// </summary>
	/// <param name="sharedName">Shared container name.</param>
	void Clear(string? sharedName = null);

	/// <summary>
	/// Sets a value for a given key.
	/// </summary>
	/// <typeparam name="T">Type of the object that is stored in this preference.</typeparam>
	/// <param name="key">The key to set the value for.</param>
	/// <param name="value">Value to set.</param>
	/// <param name="sharedName">Shared container name.</param>
	void Set<T>(string key, T value, string? sharedName = null);

	/// <summary>
	/// Gets the value for a given key, or the default specified if the key does not exist.
	/// </summary>
	/// <typeparam name="T">The type of the object stored for this preference.</typeparam>
	/// <param name="key">The key to retrieve the value for.</param>
	/// <param name="defaultValue">The default value to return when no existing value for <paramref name="key"/> exists.</param>
	/// <param name="sharedName">Shared container name.</param>
	/// <returns>Value for the given key, or the value in <paramref name="defaultValue"/> if it does not exist.</returns>
	T Get<T>(string key, T defaultValue, string? sharedName = null);
}

@sandreas
Copy link
Owner

sandreas commented Feb 8, 2025

Started an implementation experiment on https://github.com/sandreas/Avalonia.SimplePreferences. Probably take some time until release, but I think this has a much better design. We'll see if this holds.

@Diaapi
Copy link
Author

Diaapi commented Feb 8, 2025

I like it because use json instead of a local form, someone once told me that avalonia is only used for ui and has no support for native controls such as preferences

@sandreas
Copy link
Owner

sandreas commented Feb 9, 2025

There you go:
https://www.nuget.org/packages/Sandreas.Avalonia.SimplePreferences

Documentation:
https://github.com/sandreas/Avalonia.SimplePreferences

Early state but should mostly work like expected, feedback is welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants