realm / realm-object-server

Tracking of issues related to the Realm Object Server and other general issues not related to the specific SDK's
https://realm.io
293 stars 42 forks source link

Cannot modify managed objects outside of a write transaction in write block. #300

Closed xxKRASHxx closed 6 years ago

xxKRASHxx commented 6 years ago

Goals

Observe changes and make side effects on a ROS

Expected Results

Change Realm Object property

Actual Results

Error: Cannot modify managed objects outside of a write transaction. at Realm.change.realm.write

Steps to Reproduce

Subscribe on change event in ROS and try make changes on changed object.

Code Sample

observe(change: Realm.Sync.ChangeEvent) {

let perform = (change: Realm.Sync.ChangeEvent, changed: Movie) => {
            try {
                change.realm.write(() => {
                    changed.status = 'processing'
                })
            } catch (e) {
                console.log("Error on creation" + e)
            }
        }

    let allMovies = change.realm.objects('Movie')    as Realm.Results<Movie>
    perform(change, allMovies[0])
}

Version of Realm and Tooling

bigfish24 commented 6 years ago

moving this to realm-cocoa since it is an SDK issue not the server

bigfish24 commented 6 years ago

Issue moved to realm/realm-cocoa #5453 via ZenHub