Closed Bug 1141457 Opened 9 years ago Closed 9 years ago

Refactor receiveMessage in Nfc.js

Categories

(Firefox OS Graveyard :: NFC, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(firefox39 fixed)

RESOLVED FIXED
2.2 S12 (15may)
Tracking Status
firefox39 --- fixed

People

(Reporter: allstars.chh, Assigned: allstars.chh)

References

Details

(Whiteboard: [p=1])

Attachments

(3 files)

Make receiveMesssage easier in Nfc.js
Attachment #8575171 - Flags: review?(dlee) → review+
Attachment #8575173 - Flags: review?(dlee) → review+
Comment on attachment 8575174 [details] [diff] [review]
Part 3: add a CommandMsgTable.

Review of attachment 8575174 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/nfc/gonk/Nfc.js
@@ +96,5 @@
> +CommandMsgTable["NFC:ReadNDEF"] = NfcRequestType.READ_NDEF;
> +CommandMsgTable["NFC:WriteNDEF"] = NfcRequestType.WRITE_NDEF;
> +CommandMsgTable["NFC:MakeReadOnly"] = NfcRequestType.MAKE_READ_ONLY;
> +CommandMsgTable["NFC:Format"] = NfcRequestType.FORMAT;
> +CommandMsgTable["NFC:Transceive"] = NfcRequestType.TRANSCEIVE;

I am not sure if overwrite a const dictionary after declaration works according to
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const

No matter if it works i suggest we declare like this:
const CommandMsgTable = {
  "NFC:ChangeRFState":NfcRequestType.CHANGE_RF_STATE,
  ...
}
Attachment #8575174 - Flags: review?(dlee) → review+
(In reply to Dimi Lee[:dimi][:dlee] from comment #4)
> Comment on attachment 8575174 [details] [diff] [review]
> Part 3: add a CommandMsgTable.
> 
> Review of attachment 8575174 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: dom/nfc/gonk/Nfc.js
> @@ +96,5 @@
> > +CommandMsgTable["NFC:ReadNDEF"] = NfcRequestType.READ_NDEF;
> > +CommandMsgTable["NFC:WriteNDEF"] = NfcRequestType.WRITE_NDEF;
> > +CommandMsgTable["NFC:MakeReadOnly"] = NfcRequestType.MAKE_READ_ONLY;
> > +CommandMsgTable["NFC:Format"] = NfcRequestType.FORMAT;
> > +CommandMsgTable["NFC:Transceive"] = NfcRequestType.TRANSCEIVE;
> 
> I am not sure if overwrite a const dictionary after declaration works
> according to
> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/
> const
> 
> No matter if it works i suggest we declare like this:
> const CommandMsgTable = {
>   "NFC:ChangeRFState":NfcRequestType.CHANGE_RF_STATE,
>   ...
> }

Forget this comment, const object could reassign its property
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: