mk-5 / gdx-fireapp

libGDX Firebase API
Apache License 2.0
65 stars 21 forks source link

onChildChange function doesn't work #61

Closed wangdong20 closed 1 year ago

wangdong20 commented 2 years ago

Describe the bug I tried to use onChildChange function to observe ChildEvent.Added event with wanted datatype Map::class.java(Kotlin). When DB child added, but no luck.

To Reproduce Steps to reproduce the behavior:

  1. Write code: ref.inReference("users/${it.userInfo.uid}").onChildChange(Map::class.java, ChildEventType.ADDED).then(Consumer<Map<String, Any>>{// TODO})
  2. Add child by Firebase-Function
  3. Child added event doesn't trigger

Expected behavior A clear and concise description of what you expected to happen. onChildChange observe child added event with Map.class wanted datatype doesn't work when child added.

Platform (please check one of the following):

Smartphone (please complete the following information only if platform is Android or iOS):

mk-5 commented 1 year ago

@wangdong20 I think you are listening on the wrong path. According to firebase documentation:

child_added is triggered once for each existing child and then again every time a new child is added to the specified path.

You should listen on inReference("users").onChildChange(List.class, ChildEventType.ADDED). I know that you already switched yourself to official android SDK so I'm going to close the issue. Pls feel free to re-open it :)