Meteor's source code open to the clients?

前端 未结 2 2019
眼角桃花
眼角桃花 2021-02-14 00:35

From a general glimpse of it, it seems that source code for Meteor app is open to the clients due to \'Write one Javascript file, run it on client and server at once\' theme.

2条回答
  •  深忆病人
    2021-02-14 01:20

    Any code in the server/ folder will not get sent to the client (see http://docs.meteor.com/#structuringyourapp)

    EDIT

    Regarding the second part:

    Any code not in client/ or server/ is code you want to run both client and server side. So obviously it must be sent to the client.

    The reason that you would place model code in there is because of latency compensation. If you want to make updates to your data, it's best to do it immediately client-side and then run the same code server side to 'commit' it for real. There are many examples where this would make sense.

    If there is 'secret' model code that you don't want to run client side, you can certainly have a second server/models.js file.

提交回复
热议问题