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

reg-query-sub registered subscription is not returning latest value #41

Open
jleonard-r7 opened this issue Feb 2, 2022 · 6 comments
Open
Assignees

Comments

@jleonard-r7
Copy link

from REPL (after a change in the UI from 24h to 1w):

state.core=> @(rf/subscribe [::timerange])
{:timerange "24h"}
state.core=> (d/q '[:find ?t . :where [:timerange :timerange/timerange ?t]] @connection)
{:timerange "1w"}

sub is defined as:

(rp/reg-query-sub
   ::timerange
   '[:find ?t . :where [:timerange :timerange/timerange ?t]])

and the event which sets the new value is defined as:

(rp/reg-event-ds
   ::set-timerange-from-query-param
   [rf/trim-v]
   (fn-traced [_ [timerange]]
              [[:db/add :timerange :timerange/timerange (timerange/query-string-param->timerange timerange)]]))
@jleonard-r7
Copy link
Author

note also that i am using a listener to write the data to local storage:

(d/listen! connection :persistence
             (fn [tx-report]
               (when-let [db  (:db-after tx-report)]
                 (rf/dispatch [:state.local-storage/set-item storage-key (db->string db)]))))

and local storage itself contains the correct value.

@denistakeda
Copy link
Owner

Hello @jleonard-r7 . Thank you for reporting this. I'll have a look

@denistakeda denistakeda self-assigned this Feb 4, 2022
jleonard-r7 pushed a commit to jleonard-r7/re-posh that referenced this issue Feb 9, 2022
@jleonard-r7
Copy link
Author

jleonard-r7 commented Feb 9, 2022

Here is a minimal repro:
jleonard-r7@ec9351b

Just cd into that example and run:
clj -A:repl

and then in the browser that appears, click the "Click Me" button.

@denistakeda
Copy link
Owner

Thank you @jleonard-r7 . Will check this out

@denistakeda
Copy link
Owner

Hello @jleonard-r7 . I've checked the example and indeed, it works not as expected. So-far posh library is unable to watch the entities based on keyword and :db/ident rule. I'm going to support that but so far you have two workarounds:

  1. Use predefined integer ids instead
  2. Use the data storage for singleton values

Thank you for the reporting and provided repo!

@jleonard-r7
Copy link
Author

Would you mind briefly mentioning the planned fix for this and whether it would also address #47 ?

I'm beginning to hit these caching issues all across my codebase to the point that re-posh is not really usable in it current state (and that's after introducing a top-level :root object as a workaround to this, #41, the first caching issue I discovered).

If you could briefly tell me the planned fix, I could carry it out myself. Otherwise, I will unfortunately probably have to refrain from using re-posh for the time being.

Many thanks in advance for any guidance you can offer.

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

No branches or pull requests

2 participants