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

RealmConfigurationBase vs. RealmConfiguration #15

Closed
adolgov opened this issue Mar 6, 2017 · 7 comments
Closed

RealmConfigurationBase vs. RealmConfiguration #15

adolgov opened this issue Mar 6, 2017 · 7 comments
Assignees
Labels
Milestone

Comments

@adolgov
Copy link

adolgov commented Mar 6, 2017

Are there plans to allow RealmThread to work with Realm Mobile Platform (i.e. construct RealmThread from RealmConfigurationBase rather than RealmConfiguration in order to allow for a possible SyncConfiguration to be used)?

@sushihangover
Copy link
Owner

sushihangover commented Mar 6, 2017

@adolgov I originally posted that as a bug with Realm as it was a breaking change, they called it a feature :-/ The fact that you can not use the configuration returned from an Realm instance to create another Realm instance without casting it to me is a "bug" (or bad design/code smell).

I need to issue a PR from my private repo for that as I have "fixed" it for my clients are using it with 0.81.0+ w/ sync or not... I'll try to get that release on nuget.org by end day if all goes well.

Thanks for bump.

@sushihangover sushihangover modified the milestones: 0.4, 0.4.0 Mar 6, 2017
@sushihangover sushihangover self-assigned this Mar 6, 2017
@sushihangover
Copy link
Owner

sushihangover commented Mar 7, 2017

Release: https://github.com/sushihangover/RealmThread/releases/tag/0.4.0

@adolgov This is a push of the Realm.Database v.1.1.0 updates.

FYI: I need to migrate and add tests for Realm (RMP) and its notifications, so if you find any problems, please submit an issue (Thanks!)

@adolgov
Copy link
Author

adolgov commented Mar 7, 2017

What's the correct usage for RealmThread with a SyncConfiguration? The constructor only seems to take a RealmConfiguration.

@sushihangover
Copy link
Owner

sushihangover commented Mar 7, 2017

@adolgov Realm.Thread is dependent only on Realm.Database so users not using RMP do not have to install Realm (which holds a dependency to Realm.Database), thus RealmThread is looking for a RealmConfigurationBase.

Pass a RealmConfigurationBase from:

  • A Realm instance that was already created with a SyncConfiguration (Realm.Config property)
  • A non-synced RealmConfiguration-based instance (Realm.Config property)
  • Pass a RealmConfiguration directly to create a stand-alone non-synced Realm instance

i.e.:

	const string realmDBName = "SyncingWith.Realm";
	RealmThread realmThread;
	var uri = new Uri("http://caliroll:9080");
	await User.LoginAsync(Credentials.UsernamePassword("sushi@not.exist", "sushi", false), uri);
	var user = User.Current;
	if (user != null)
	{
		var url = new Uri("realm://caliroll/2MillionRecordSyncTest.Realm");
		var syncConf = new SyncConfiguration(user, uri, realmDBName);

		masterRealmInstance = Realms.Realm.GetInstance(syncConf);
		realmThread = new RealmThread(masterRealmInstance.Config);
	}
	else
	{
		masterRealmInstance = Realms.Realm.GetInstance(realmDBName);
		realmThread = new RealmThread(new RealmConfiguration(realmDBName));
	}

	if (masterRealmInstance.All<ARealmObject>().Count() == 0)
	{
		realmThread.Invoke((Realms.Realm r) =>
		{
			CreateAndUpdateByGroup(1024 * 1024 * 2, 1024 * 4);
		});
	};

@adolgov
Copy link
Author

adolgov commented Mar 8, 2017

This is what I was expecting; however, when I try to construct a new RealmThread(...), I only have a constructor for RealmConfiguration rather than RealmConfigurationBase. I'm using the latest (0.4.0) from nuget.

This is in a PCL project. I'm not sure how the RealmThread project is structured, but I did notice that the RealmThread.Shared project has the constructor defined with RealmConfigurationBase; however, the RealmThread.Portable project still requires RealmConfiguration.

@sushihangover sushihangover reopened this Mar 8, 2017
@sushihangover
Copy link
Owner

@adolgov You ca absolutely correct, that would be a bug, I missed the PCL updates

Issue #17

@sushihangover
Copy link
Owner

@adolgov I just pushed an updated Nuget from AppVeyor (SushiHangover.RealmThread.0.4.1.nupkg) it should just work now (but I have not tested it directly: #19)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants