-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
POC exploring a potential projections API
- Loading branch information
Christian Melchior
committed
Oct 10, 2023
1 parent
0cc98c0
commit d5d721a
Showing
18 changed files
with
414 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
...library-base/src/commonMain/kotlin/io/realm/kotlin/notifications/ProjectedObjectChange.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright 2021 Realm Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.realm.kotlin.notifications | ||
|
||
public sealed interface SingleProjectionQueryChange<O : Any> { | ||
/** | ||
* Returns the newest state of object being observed. `null` is returned if there is no object to | ||
* observe. | ||
*/ | ||
public val obj: O? | ||
} | ||
|
||
/** | ||
* TODO Docs | ||
*/ | ||
public interface PendingProjection<O : Any> : SingleProjectionQueryChange<O> | ||
|
||
/** | ||
* TODO Docs | ||
* TODO Annoying to have both `ProjectionsChanges` and `ProjectionChange`...other name for one of them? | ||
*/ | ||
public sealed interface ProjectionChange<O : Any> : SingleProjectionQueryChange<O> { | ||
/** | ||
* Returns the newest state of object being observed. `null` is returned if the object | ||
* has been deleted. | ||
*/ | ||
override val obj: O? | ||
} | ||
|
||
/** | ||
* TODO Docs | ||
*/ | ||
public interface InitialProjection<O : Any> : SingleProjectionQueryChange<O> { | ||
override val obj: O | ||
} | ||
|
||
/** | ||
* TODO Docs | ||
* TODO Can we actually track all changed fields? | ||
*/ | ||
public interface UpdatedProjection<O : Any> : SingleProjectionQueryChange<O> { | ||
override val obj: O | ||
|
||
/** | ||
* Returns the names of properties that has changed. | ||
*/ | ||
public val changedFields: Array<String> | ||
|
||
/** | ||
* Checks if a given field has been changed. | ||
* | ||
* @param fieldName to be checked if its value has been changed. | ||
* @return `true` if the field has been changed. It returns `false` the field cannot be found | ||
* or the field hasn't been changed. | ||
*/ | ||
public fun isFieldChanged(fieldName: String): Boolean { | ||
return changedFields.firstOrNull { it == fieldName } != null | ||
} | ||
} | ||
|
||
/** | ||
* TODO Docs | ||
*/ | ||
public interface DeletedProjection<O : Any> : ProjectionChange<O> |
33 changes: 33 additions & 0 deletions
33
...ges/library-base/src/commonMain/kotlin/io/realm/kotlin/notifications/ProjectionsChange.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2022 Realm Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.realm.kotlin.notifications | ||
|
||
/** | ||
* TODO Docs (copy from ResultsChange) | ||
*/ | ||
public sealed interface ProjectionsChange<T : Any> { | ||
public val list: List<T> | ||
} | ||
|
||
/** | ||
* TODO Docs (copy from ResultsChange) | ||
*/ | ||
public interface InitialProjections<T : Any> : ProjectionsChange<T> | ||
|
||
/** | ||
* TODO Docs (copy from ResultsChange) | ||
*/ | ||
public interface UpdatedProjections<T : Any> : ProjectionsChange<T>, ListChangeSet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.