你可以使用on child_added监听器在firebase中使用通配符或globs吗?

时间:2015-08-30 12:27:31

标签: firebase

我本质上想做一个grandchild_added事件监听器。

看着孩子和文档,我无法弄清楚是否有办法在引用中设置通配符,以便它可以监视整个引用模式。

https://www.firebase.com/docs/web/api/firebase/child.html https://www.firebase.com/docs/web/api/query/on.html

给出了像这样的firebase数据:

    TCHAR pszDest[arraysize]; 
    size_t cbDest = arraysize * sizeof(TCHAR);

    LPCTSTR pszFormat = TEXT("%s %d + %d = %d.");
    TCHAR* pszTxt = TEXT("The answer is");

    HRESULT hr = StringCbPrintf(pszDest, cbDest, pszFormat, pszTxt, 1, 2, 3);

                if(hr == S_OK)
                {
                MessageBox(hWnd, pszDest, L"Information", MB_OK);

                }
                else
                {

                swprintf_s(hrtext, sizeof(hrtext), L"StringCbPrintf didn't work, quitting: code %#08X" , hr);

                MessageBox(hWnd, hrtext, L"Warning", MB_OK);
                }
    EndDialog(hWnd, 0);
    return FALSE;

例如我可以这样做吗?

-messages
  -roomA
    -hi a
    -hello everyone a
  -roomB
    -hi b

如果我可以提供帮助,我不想单独为每个房间添加一个单独的参考,因为那会更复杂,我不确定它是否也会表现得那么好。

1 个答案:

答案 0 :(得分:3)

不。 child_added事件会在您将其附加到的位置下侦听一个级别。

如果您附加到用户的messages位置,Firebase会在向房间添加消息时触发child_changed事件和value事件。