Giter Site home page Giter Site logo

Comments (5)

pgilmorepf avatar pgilmorepf commented on August 12, 2024 1

The latest published npm package solves the problem.

You can install the package, and then access it like this:

var playfab = require("playfab-sdk");

for(var each in playfab)
{
    console.log("Each : " + each);
}

for(var each in playfab.settings)
{
    console.log("Each.settings : " + each);
}

from nodesdk.

pgilmorepf avatar pgilmorepf commented on August 12, 2024

https://github.com/PlayFab/NodeSDK/tree/master/PlayFabTestingExample
This is our testing project.
In order to be published, the following steps must occur:
The vs solution must build with no errors (this is mostly to test the typescript bindings)
Then we execute a suite of tests via test.bat, which executes this file:
https://github.com/PlayFab/NodeSDK/blob/master/PlayFabTestingExample/PlayFabApiTests.js
Those tests must all execute, pass, and be relayed to our test-system, in order for our build to pass, which is a requirement for publishing (publishing to npm is another step in the same job).
I obviously can't test that the npm module works from npm, before I even publish it to npm, so I try to mimic the final structure of the node module in my test project.

From that testing file I can guarantee you a few things:
The test file does this:
var PlayFab = require("./Scripts/PlayFab/PlayFab");
And https://github.com/PlayFab/NodeSDK/blob/master/PlayFabSdk/Scripts/PlayFab/PlayFabClient.js does this:
var PlayFab = require("./PlayFab.js");
So, your specific point about whether require returns the same object or not:
PlayFab.settings.titleId = TitleData.titleId;
And PlayFabClient.js reads it from the same object:
request.TitleId = PlayFab.settings.titleId != null ? PlayFab.settings.titleId : request.TitleId;
And this is demonstrably working.
So, I disagree with your statement, I think that require does indeed return the same object when called from multiple files.

As for the npm module itself:
I tested it when we first created it, and my test environment is designed to mimic the structure of the npm module once fetched.
You are attempting require statements which differ slightly from mine, so I may have accidentally designed it in some non-standard way. This is fixable of course, and I'm happy to work with you to do so.

The best way to resolve this I think is for you to join our PlayFab Community Slack channel, and we can work out the details of the fix via a faster communication method.
https://api.playfab.com/slack
and then contact me directly: @pgilmore

I'll leave this open for now, pending the resolution.

from nodesdk.

gmlion avatar gmlion commented on August 12, 2024

While I'm sure require return the same object for multiple files in the project, it looks like it's not guaranteed when one of the require resides in a module:
http://justjs.com/posts/singletons-in-node-js-modules-cannot-be-trusted-or-why-you-can-t-just-do-var-foo-require-baz-init

There is the possibility this particular situation allows for your approach, but I suspect it's not idiomatic (and could break in the future anyway) but I couldn't test it because I couldn't import the objects directly anyway.

I will join the slack channel in the following days to discuss the other topic, until then thank you for your time.

from nodesdk.

pgilmorepf avatar pgilmorepf commented on August 12, 2024

Hello again.

If you check the https://github.com/PlayFab/NodeSDK/tree/T3626 branch, you can see that we're working on an alternate version of the node package, which should resolve all of the issues we discussed.

Please take a look and let us know if it handles all the issues you found.

Thanks!

from nodesdk.

yehtutwin avatar yehtutwin commented on August 12, 2024

var playfab = require("playfab-sdk");

var PlayFab = playfab.PlayFab;
var PlayFabClient = playfab.PlayFabClient;

from nodesdk.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.