Title: when a record is destroyed make sure all "reactivity" is turned off during the update · Issue #195 · hyperstack-org/hyperstack · GitHub
Open Graph Title: when a record is destroyed make sure all "reactivity" is turned off during the update · Issue #195 · hyperstack-org/hyperstack
X Title: when a record is destroyed make sure all "reactivity" is turned off during the update · Issue #195 · hyperstack-org/hyperstack
Description: For example this spec will fail: context "updating a has_many relationship" do before(:each) do m = FactoryBot.create(:test_model, test_attribute: 'hello') FactoryBot.create(:child_model, test_model: m) mount "TestComponent3" do class In...
Open Graph Description: For example this spec will fail: context "updating a has_many relationship" do before(:each) do m = FactoryBot.create(:test_model, test_attribute: 'hello') FactoryBot.create(:child_model, test_mode...
X Description: For example this spec will fail: context "updating a has_many relationship" do before(:each) do m = FactoryBot.create(:test_model, test_attribute: 'hello') FactoryBot.create(:chil...
Opengraph URL: https://github.com/hyperstack-org/hyperstack/issues/195
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"when a record is destroyed make sure all \"reactivity\" is turned off during the update","articleBody":"For example this spec will fail:\r\n```ruby\r\n context \"updating a has_many relationship\" do\r\n\r\n before(:each) do\r\n\r\n m = FactoryBot.create(:test_model, test_attribute: 'hello')\r\n FactoryBot.create(:child_model, test_model: m)\r\n\r\n mount \"TestComponent3\" do\r\n class InnerComponent \u003c HyperComponent\r\n param :child\r\n render { LI { \"child id = #{@Child.id} #{@Child.test_model.test_attribute}\"} }\r\n end\r\n class TestComponent3 \u003c HyperComponent\r\n render(OL) do\r\n TestModel.all[0].child_models.each do |child|\r\n InnerComponent(child: child)\r\n end\r\n end\r\n end\r\n end\r\n page.should have_content('child id = 1')\r\n end\r\n\r\n it \"will update when sent from the server\" do\r\n ChildModel.create(child_attribute: :foo, test_model: TestModel.find(1))\r\n page.should have_content('child id = 2')\r\n ChildModel.find(1).destroy\r\n sleep 0.1 # necessary for poltergeist to work with pusher faker\r\n page.should_not have_content('child id = 1', wait: 2)\r\n page.should have_content('child id = 2')\r\n end\r\nend\r\n```\r\nbecause `InnerComponent` accesses the child's `test_model`, which is set to nil when the child is destroyed (because we want to keep all the linkages nicely synchronized) but setting this to nil causes the component to re-rerender. \r\n\r\nHere is a patch (not fully tested)\r\n\r\n```ruby\r\nmodule ReactiveRecord\r\n class Base\r\n alias destroy_associations_before_patch destroy_associations\r\n def destroy_associations(*args, \u0026block)\r\n @being_destroyed = true\r\n destroy_associations_before_patch\r\n end\r\n\r\n alias change_status_and_notify_helper_before_patch change_status_and_notify_helper\r\n def change_status_and_notify_helper(*args, \u0026block)\r\n return if @being_destroyed\r\n change_status_and_notify_helper_before_patch(*args, \u0026block)\r\n end\r\n end\r\nend\r\n```\r\n\r\nNote that simply wrapping the `destroy_associations` method with the `Base.loading` method will not work, as this will turn off notification for both sides of the relationship. I.e. the has_many side will never re-render either, which it should.","author":{"url":"https://github.com/catmando","@type":"Person","name":"catmando"},"datePublished":"2019-06-12T20:42:37.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/195/hyperstack/issues/195"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:fa7db553-dd77-8bed-9836-d96a217cc14f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B05E:804D0:12D7579:1817A7B:69919E51 |
| html-safe-nonce | bcb9f9d3617303821950d4f4d9a76367ada6214d42f26ba64fff24de1add5e38 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMDVFOjgwNEQwOjEyRDc1Nzk6MTgxN0E3Qjo2OTkxOUU1MSIsInZpc2l0b3JfaWQiOiI1MzExMzMwNzgxMDU4MTQ1ODczIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e0718b2d54ebf3dc54a92bc6a62394e7446cad03c45b857256fc9f766985ff30 |
| hovercard-subject-tag | issue:455415230 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/hyperstack-org/hyperstack/195/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e0cd238f1127aa2b1800a66b1d4f0e34f2d9f3d3bff037e1db8da0be47c31b10/hyperstack-org/hyperstack/issues/195 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e0cd238f1127aa2b1800a66b1d4f0e34f2d9f3d3bff037e1db8da0be47c31b10/hyperstack-org/hyperstack/issues/195 |
| og:image:alt | For example this spec will fail: context "updating a has_many relationship" do before(:each) do m = FactoryBot.create(:test_model, test_attribute: 'hello') FactoryBot.create(:child_model, test_mode... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | catmando |
| hostname | github.com |
| expected-hostname | github.com |
| None | 42c603b9d642c4a9065a51770f75e5e27132fef0e858607f5c9cb7e422831a7b |
| turbo-cache-control | no-preview |
| go-import | github.com/hyperstack-org/hyperstack git https://github.com/hyperstack-org/hyperstack.git |
| octolytics-dimension-user_id | 34562730 |
| octolytics-dimension-user_login | hyperstack-org |
| octolytics-dimension-repository_id | 145879576 |
| octolytics-dimension-repository_nwo | hyperstack-org/hyperstack |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 145879576 |
| octolytics-dimension-repository_network_root_nwo | hyperstack-org/hyperstack |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 848bc6032dcc93a9a7301dcc3f379a72ba13b96e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width