How can I make a lightning component change as the underlying data changes without refreshing?
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
4
down vote
favorite
I'm writing a lightning page that allows two players to remotely play chess through the same lightning page. The page uses the aura framework.
For what I've already implemented, the Game__c
object has two lookup fields to a user- one for each player- and only lets the correct player move a piece on their turn. Moreover, when the page loads, it loads the correct board position.
However, when a player moves a piece, the board does not update on their opponent's screen- the opponent has to refresh to see the update.
How can I make the board update in as soon as the active player makes their move?
apex lightning controller aura
New contributor
add a comment |
up vote
4
down vote
favorite
I'm writing a lightning page that allows two players to remotely play chess through the same lightning page. The page uses the aura framework.
For what I've already implemented, the Game__c
object has two lookup fields to a user- one for each player- and only lets the correct player move a piece on their turn. Moreover, when the page loads, it loads the correct board position.
However, when a player moves a piece, the board does not update on their opponent's screen- the opponent has to refresh to see the update.
How can I make the board update in as soon as the active player makes their move?
apex lightning controller aura
New contributor
add a comment |
up vote
4
down vote
favorite
up vote
4
down vote
favorite
I'm writing a lightning page that allows two players to remotely play chess through the same lightning page. The page uses the aura framework.
For what I've already implemented, the Game__c
object has two lookup fields to a user- one for each player- and only lets the correct player move a piece on their turn. Moreover, when the page loads, it loads the correct board position.
However, when a player moves a piece, the board does not update on their opponent's screen- the opponent has to refresh to see the update.
How can I make the board update in as soon as the active player makes their move?
apex lightning controller aura
New contributor
I'm writing a lightning page that allows two players to remotely play chess through the same lightning page. The page uses the aura framework.
For what I've already implemented, the Game__c
object has two lookup fields to a user- one for each player- and only lets the correct player move a piece on their turn. Moreover, when the page loads, it loads the correct board position.
However, when a player moves a piece, the board does not update on their opponent's screen- the opponent has to refresh to see the update.
How can I make the board update in as soon as the active player makes their move?
apex lightning controller aura
apex lightning controller aura
New contributor
New contributor
New contributor
asked 2 days ago
SarcasticSully
1233
1233
New contributor
New contributor
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
5
down vote
accepted
Very very interesting question.
Using Platform Events and lightning:empAPI : This can be solved by Platform events, whenever a player makes a move, fire a platform event. Also as a listener use lightning:empAPI in both the components.
When 1 player makes a move, the other player's components gets notified and he reacts accordingly by refreshing the view or moving that piece via code.
Using Lightning Data Services: This might be another way to handle this. According to docs/DF18 session, LDS automatically uses streaming API so that all screens have fresh data, not sure how effective it is.
1
Seems promising, but [in both the components] -- is actually the instance of same component, so an event fired and subscribed sits on the same component, thus it may get complex as which User need to fire vs. which User need to subscribe to the event.
– Jayant Das
2 days ago
Can be bit challenging, but I have built something similar that the event though fires only the people who mentioned in will react to it.
– Pranay Jaiswal
2 days ago
add a comment |
up vote
1
down vote
There is a new feature mentioned at DF 18 called Live Records, that will be part of Lightning Data Service, which I think is based on the new Change Data Capture feature, but I think it is only in Dev Preview right now:
https://developer.salesforce.com/blogs/2018/08/what-is-change-data-capture.html
If you look at this DF session, you'll see a demo of it doing pretty much what you are describing - user 1 is viewing a record and it is changed by another user - and the change will be automatically made on user 1's screen without requiring a refresh. So might be worth seeing if you can get access to that since you have a good use case there
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
Very very interesting question.
Using Platform Events and lightning:empAPI : This can be solved by Platform events, whenever a player makes a move, fire a platform event. Also as a listener use lightning:empAPI in both the components.
When 1 player makes a move, the other player's components gets notified and he reacts accordingly by refreshing the view or moving that piece via code.
Using Lightning Data Services: This might be another way to handle this. According to docs/DF18 session, LDS automatically uses streaming API so that all screens have fresh data, not sure how effective it is.
1
Seems promising, but [in both the components] -- is actually the instance of same component, so an event fired and subscribed sits on the same component, thus it may get complex as which User need to fire vs. which User need to subscribe to the event.
– Jayant Das
2 days ago
Can be bit challenging, but I have built something similar that the event though fires only the people who mentioned in will react to it.
– Pranay Jaiswal
2 days ago
add a comment |
up vote
5
down vote
accepted
Very very interesting question.
Using Platform Events and lightning:empAPI : This can be solved by Platform events, whenever a player makes a move, fire a platform event. Also as a listener use lightning:empAPI in both the components.
When 1 player makes a move, the other player's components gets notified and he reacts accordingly by refreshing the view or moving that piece via code.
Using Lightning Data Services: This might be another way to handle this. According to docs/DF18 session, LDS automatically uses streaming API so that all screens have fresh data, not sure how effective it is.
1
Seems promising, but [in both the components] -- is actually the instance of same component, so an event fired and subscribed sits on the same component, thus it may get complex as which User need to fire vs. which User need to subscribe to the event.
– Jayant Das
2 days ago
Can be bit challenging, but I have built something similar that the event though fires only the people who mentioned in will react to it.
– Pranay Jaiswal
2 days ago
add a comment |
up vote
5
down vote
accepted
up vote
5
down vote
accepted
Very very interesting question.
Using Platform Events and lightning:empAPI : This can be solved by Platform events, whenever a player makes a move, fire a platform event. Also as a listener use lightning:empAPI in both the components.
When 1 player makes a move, the other player's components gets notified and he reacts accordingly by refreshing the view or moving that piece via code.
Using Lightning Data Services: This might be another way to handle this. According to docs/DF18 session, LDS automatically uses streaming API so that all screens have fresh data, not sure how effective it is.
Very very interesting question.
Using Platform Events and lightning:empAPI : This can be solved by Platform events, whenever a player makes a move, fire a platform event. Also as a listener use lightning:empAPI in both the components.
When 1 player makes a move, the other player's components gets notified and he reacts accordingly by refreshing the view or moving that piece via code.
Using Lightning Data Services: This might be another way to handle this. According to docs/DF18 session, LDS automatically uses streaming API so that all screens have fresh data, not sure how effective it is.
answered 2 days ago
Pranay Jaiswal
10.6k31950
10.6k31950
1
Seems promising, but [in both the components] -- is actually the instance of same component, so an event fired and subscribed sits on the same component, thus it may get complex as which User need to fire vs. which User need to subscribe to the event.
– Jayant Das
2 days ago
Can be bit challenging, but I have built something similar that the event though fires only the people who mentioned in will react to it.
– Pranay Jaiswal
2 days ago
add a comment |
1
Seems promising, but [in both the components] -- is actually the instance of same component, so an event fired and subscribed sits on the same component, thus it may get complex as which User need to fire vs. which User need to subscribe to the event.
– Jayant Das
2 days ago
Can be bit challenging, but I have built something similar that the event though fires only the people who mentioned in will react to it.
– Pranay Jaiswal
2 days ago
1
1
Seems promising, but [in both the components] -- is actually the instance of same component, so an event fired and subscribed sits on the same component, thus it may get complex as which User need to fire vs. which User need to subscribe to the event.
– Jayant Das
2 days ago
Seems promising, but [in both the components] -- is actually the instance of same component, so an event fired and subscribed sits on the same component, thus it may get complex as which User need to fire vs. which User need to subscribe to the event.
– Jayant Das
2 days ago
Can be bit challenging, but I have built something similar that the event though fires only the people who mentioned in will react to it.
– Pranay Jaiswal
2 days ago
Can be bit challenging, but I have built something similar that the event though fires only the people who mentioned in will react to it.
– Pranay Jaiswal
2 days ago
add a comment |
up vote
1
down vote
There is a new feature mentioned at DF 18 called Live Records, that will be part of Lightning Data Service, which I think is based on the new Change Data Capture feature, but I think it is only in Dev Preview right now:
https://developer.salesforce.com/blogs/2018/08/what-is-change-data-capture.html
If you look at this DF session, you'll see a demo of it doing pretty much what you are describing - user 1 is viewing a record and it is changed by another user - and the change will be automatically made on user 1's screen without requiring a refresh. So might be worth seeing if you can get access to that since you have a good use case there
add a comment |
up vote
1
down vote
There is a new feature mentioned at DF 18 called Live Records, that will be part of Lightning Data Service, which I think is based on the new Change Data Capture feature, but I think it is only in Dev Preview right now:
https://developer.salesforce.com/blogs/2018/08/what-is-change-data-capture.html
If you look at this DF session, you'll see a demo of it doing pretty much what you are describing - user 1 is viewing a record and it is changed by another user - and the change will be automatically made on user 1's screen without requiring a refresh. So might be worth seeing if you can get access to that since you have a good use case there
add a comment |
up vote
1
down vote
up vote
1
down vote
There is a new feature mentioned at DF 18 called Live Records, that will be part of Lightning Data Service, which I think is based on the new Change Data Capture feature, but I think it is only in Dev Preview right now:
https://developer.salesforce.com/blogs/2018/08/what-is-change-data-capture.html
If you look at this DF session, you'll see a demo of it doing pretty much what you are describing - user 1 is viewing a record and it is changed by another user - and the change will be automatically made on user 1's screen without requiring a refresh. So might be worth seeing if you can get access to that since you have a good use case there
There is a new feature mentioned at DF 18 called Live Records, that will be part of Lightning Data Service, which I think is based on the new Change Data Capture feature, but I think it is only in Dev Preview right now:
https://developer.salesforce.com/blogs/2018/08/what-is-change-data-capture.html
If you look at this DF session, you'll see a demo of it doing pretty much what you are describing - user 1 is viewing a record and it is changed by another user - and the change will be automatically made on user 1's screen without requiring a refresh. So might be worth seeing if you can get access to that since you have a good use case there
answered 2 days ago
BritishBoyinDC
8,8422762
8,8422762
add a comment |
add a comment |
SarcasticSully is a new contributor. Be nice, and check out our Code of Conduct.
SarcasticSully is a new contributor. Be nice, and check out our Code of Conduct.
SarcasticSully is a new contributor. Be nice, and check out our Code of Conduct.
SarcasticSully is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f239531%2fhow-can-i-make-a-lightning-component-change-as-the-underlying-data-changes-witho%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown