Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

964 enum circular dep react native #994

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/enum.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = Enum;
var ReflectionObject = require("./object");
((Enum.prototype = Object.create(ReflectionObject.prototype)).constructor = Enum).className = "Enum";

var Namespace = require("./namespace"),
var getNamespace = function () { return require("./namespace") },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there another way, like reordering imports? Asking because there's already a more general workaround in place for similar cases that doesn't require calling a function each time, and instead sets these things up on instantiation.

Copy link
Contributor Author

@leonardpauli leonardpauli Apr 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, neat! Updated it :)

Ps. had some fun with node --max_inlined_bytecode_size=0 test.js, not sure if the extra function call would have mattered in execution, though using existing logic is preferred!

util = require("./util");

/**
Expand Down Expand Up @@ -168,7 +168,7 @@ Enum.prototype.remove = function remove(name) {
* @returns {boolean} `true` if reserved, otherwise `false`
*/
Enum.prototype.isReservedId = function isReservedId(id) {
return Namespace.isReservedId(this.reserved, id);
return getNamespace().isReservedId(this.reserved, id);
};

/**
Expand All @@ -177,5 +177,5 @@ Enum.prototype.isReservedId = function isReservedId(id) {
* @returns {boolean} `true` if reserved, otherwise `false`
*/
Enum.prototype.isReservedName = function isReservedName(name) {
return Namespace.isReservedName(this.reserved, name);
return getNamespace().isReservedName(this.reserved, name);
};